PApp::Lock - manage locks using sql
use PApp::Lock; # not auto-imported into .papp-files locked { ... locked code section } "my_app_lock", 60, 60*10;
This module manages locking (semaphores) using the papp state database (i.e. it works without filesystem and across hosts).
Execute the given BLOCK while holding the lock NAME. The lock will be given up as soon as the block is left. See the new method for the meaning of the arguments.
new
Create a new lock object (but do not lock it) of name name. The name might be used case-sensitive or -insensitive, so always use the same spel[l]ing but don't expect that lock names are case-sensitive. timeout specifies the maximum time that the program waits until the lock becomes available (default: 5 minutes). holdtime specifies the maximum age the lock can have (default: 12 hours). A lock older than holdtime is broken.
name
timeout
holdtime
Tries to aquire the lock until the timeout is reached. Returns true when the lock was aquired and false when the lock couldn't be aquired.
See new for the meaning of timeout.
Returns the time when the lock can be broken (by another application). This can be called even when the process does not hold the lock. If the lock is not used it will return nothing.
PApp.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
To install PApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PApp
CPAN shell
perl -MCPAN -e shell install PApp
For more information on module installation, please visit the detailed CPAN module installation guide.