ExclusiveLock::Guard - lexically-scoped lock management
use ExclusiveLock::Guard; sub blocking_transaction { my $lock = ExclusiveLock::Guard->new('/tmp/foo.lock') or die 'lock error: ' . ExclusiveLock::Guard->errstr; # inner of lock } blocking_transaction(); # outer of lock
for non-blocking
sub nonblocking_transaction { my $lock = ExclusiveLock::Guard->new('/tmp/foo.lock', nonblocking => 1 ) or die 'lock error: ' . ExclusiveLock::Guard->errstr; unless ($lock->is_locked) { warn 'is locked'; return; } # inner of lock } nonblocking_transaction(); # outer of lock
ExclusiveLock::Guard is very simple lock maneger. To automatically create and remove the lock file.
Kazuhiro Osawa <yappo {at} shibuya {dot} pl>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install ExclusiveLock::Guard, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ExclusiveLock::Guard
CPAN shell
perl -MCPAN -e shell install ExclusiveLock::Guard
For more information on module installation, please visit the detailed CPAN module installation guide.