Semaphore (semaphore v1.2.0)
Link to this section Summary
Functions
Acquire a semaphore, incrementing the internal count by one.
Acquire a semaphore, incrementing the internal count by one.
Attempt to acquire a semaphore and call a function and then automatically release.
Attempt to acquire a semaphore and call a function that might link to another process, and then automatically release.
Returns a specification to start this module under a supervisor.
Number of acquired semaphores.
Callback implementation for GenServer.init/1
.
Release a semaphore, decrementing the internal count by one.
Release a semaphore, decrementing the internal count by one.
Reset sempahore to a specific count.
Link to this section Functions
acquire(name, max)
Acquire a semaphore, incrementing the internal count by one.
acquire_linksafe(name, id, max)
Acquire a semaphore, incrementing the internal count by one.
If the current process exits without releasing the semaphore, it will be automatically swept in the background. Like
call_linksafe
, tThis function has higher overhead than acquire/2
.
call(name, max, func)
Attempt to acquire a semaphore and call a function and then automatically release.
call_linksafe(name, max, func)
Attempt to acquire a semaphore and call a function that might link to another process, and then automatically release.
If the current process dies in a way that is unable to be caught by the try block (e.g. a linked process dies, while
func
is being called. The semaphore will be automatically released by the sweeper in the background.
This function has higher overhead than call/3
and should only be used if you know that you might be linking to
something in the func.
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
count(name)
Number of acquired semaphores.
init(sweep_interval)
Callback implementation for GenServer.init/1
.
release(name)
@spec release(term()) :: :ok
Release a semaphore, decrementing the internal count by one.
release_linksafe(name, id)
Release a semaphore, decrementing the internal count by one.
If the current process exits without releasing the semaphore, it will be automatically swept in the background. Like
call_linksafe
, tThis function has higher overhead than acquire/2
.
reset(name, count \\ 0)
Reset sempahore to a specific count.