IO::Lambda::Flock - lambda-style file locking
The module provides file locking interface for the lambda style, implemented by using non-blocking, periodic polling of flock(2).
open LOCK, ">lock"; lambda { # obtain the lock context \*LOCK, timeout => 10; flock { die "can't obtain lock" unless shift } # while reading from handle context $handle; readable { ... } # and showing status context 0.5; timeout { print '.'; again } };
Waits until the file lock is obtained or the timeout is expired. When successful, the (shared or exclusive) lock on $filehandle is acquired by flock($filehandle, LOCK_NB) call. Options:
$filehandle
flock($filehandle, LOCK_NB)
timeout
deadline
These two options are synonyms, both declare the moment when the lambda waiting for the lock should give up. If undef, timeout never occurs.
If set, LOCK_SH is used, otherwise LOCK_EX.
LOCK_SH
LOCK_EX
Defines how often the polling for the lock should occur. If left undefined, polling occurs during idle time, when other events are dispatched.
Fcntl, IO::Lambda::Poll.
Dmitry Karasik, <dmitry@karasik.eu.org>.
To install IO::Lambda, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Lambda
CPAN shell
perl -MCPAN -e shell install IO::Lambda
For more information on module installation, please visit the detailed CPAN module installation guide.