Skip to content

Commit

Permalink
Export sema_nif type (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
saleyn authored Oct 19, 2023
1 parent b7e2ad6 commit 6946961
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/sema_nif.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@
release/3
]).

-export_type([sema_ref/0, acquire_ret/0, release_ret/0]).

-on_load(init/0).

-define(APPNAME, sema_nif).
-define(LIBNAME, sema_nif).

-opaque sema_ref() :: reference().
-type acquire_ret() ::
% process got resource unit, return number of units acquired so far
{ok, N :: pos_integer()}
% no resource units available
| {error, full}.

-type release_ret() ::
% process freed resource unit, return number of units acquired after that
{ok, N :: pos_integer()}
% no process that holds resource found
| {error, not_found}.

-type sema_ref() :: reference().

-export_type([sema_ref/0, acquire_ret/0, release_ret/0]).

-spec create(Max :: pos_integer()) -> sema_ref().
create(_) -> not_loaded(?LINE).
Expand All @@ -44,12 +56,6 @@ create(_) -> not_loaded(?LINE).
}.
info(_) -> not_loaded(?LINE).

-type acquire_ret() ::
% process got resource unit, return number of units acquired so far
{ok, N :: pos_integer()}
% no resource units available
| {error, full}.

% acquire resource unit for calling process, monitor process
-spec acquire(Semaphore :: sema_ref()) -> Ret :: acquire_ret().
acquire(_) -> not_loaded(?LINE).
Expand All @@ -58,12 +64,6 @@ acquire(_) -> not_loaded(?LINE).
-spec acquire(Semaphore :: sema_ref(), Cnt :: pos_integer()) -> Ret :: acquire_ret().
acquire(_, _) -> not_loaded(?LINE).

-type release_ret() ::
% process freed resource unit, return number of units acquired after that
{ok, N :: pos_integer()}
% no process that holds resource found
| {error, not_found}.

% release resource unit acquired by calling process
-spec release(Semaphore :: sema_ref()) -> Ret :: release_ret().
release(_) -> not_loaded(?LINE).
Expand Down

0 comments on commit 6946961

Please sign in to comment.