In Lock::Async§
See primary documentation in context for method unlock
method unlock(Lock::Async:D: --> Nil)
Releases the lock. If there are any outstanding lock
Promise
s, the one at the head of the queue will then be kept, and potentially code scheduled on the thread pool (so the cost of calling unlock
is limited to the work needed to schedule another piece of code that wants to obtain the lock, but not to execute that code).
my $l = Lock::Async.new; await $l.lock; $l.unlock;
Prefer to use protect instead of explicit calls to lock
and unlock
. However, if wishing to use the methods separately, it is wise to use a LEAVE
block to ensure that unlock
is reliably called. Failing to unlock
will mean that nobody can ever lock
this particular Lock::Async
instance again.
my $l = Lock::Async.new; { await $l.lock; LEAVE $l.unlock; }
In IO::Handle§
See primary documentation in context for method unlock
method unlock(IO::Handle:D: --> True)
Removes a lock
from the filehandle. It will return True
or fail with an exception if it's not possible.
In IO::CatHandle§
See primary documentation in context for method unlock
method unlock(IO::CatHandle:D:)
Same as IO::Handle.unlock
. Returns Nil
if the source handle queue has been exhausted.
Unlocks only the currently active source handle. The .on-switch
Callable
can be used to conveniently lock/unlock the handles as they're being processed by the CatHandle.
In Lock§
See primary documentation in context for method unlock
method unlock(Lock:D:)
Releases the lock.
my $l = Lock.new; $l.lock; $l.unlock;
It is important to make sure the Lock
is always released, even if an exception is thrown. The safest way to ensure this is to use the protect
method, instead of explicitly calling lock
and unlock
. Failing that, use a LEAVE
phaser.
my $l = Lock.new; { $l.lock; LEAVE $l.unlock; }