misha_cafex v0.0.6 Cafex.Lock behaviour
A general, backend-pluggable lock implementation.
It’s an FSM.
Summary
Functions
Non-blocking function to acquire a lock
Callbacks
Handle acquire callback
Types
Functions
Non-blocking function to acquire a lock
The args is pass to locker.init(args).
If at first it hold the lock, this function will return {:ok, pid}.
Or else, it will return {:error, :locked} and stop the FSM if timeout is 0.
Or it will return {:wait, pid} if timeout is other then 0, and the FSM will
wait for the lock until timeout.
The caller will receive a message {:lock, :ok} if it get the lock before timeout,
or {:lock, :timeout} and then stop.
NOTE: The caller process is linked to the FSM process.
Callbacks
Handle acquire callback
Non-blocking function, return {:ok, state} if acquired the lock.
Or {:wait, state} if waiting the lock, continue waiting in a asynchronized way(i.e. a process),
then if lock changed, a :lock_changed message will send to this process.