Coro::Semaphore - non-binary semaphores
use Coro::Semaphore; $sig = new Coro::Semaphore [initial value]; $sig->down; # wait for signal # ... some other "thread" $sig->up;
Creates a new sempahore object with the given initial lock count. The default lock count is 1, which means it is unlocked by default.
Decrement the counter, therefore "locking" the semaphore. This method waits until the semaphore is available if the counter is zero.
Unlock the semaphore again.
Try to down the semaphore. Returns true when this was possible, otherwise return false and leave the semaphore unchanged.
down
Marc Lehmann <pcg@goof.com> http://www.goof.com/pcg/marc/
To install Coro, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Coro
CPAN shell
perl -MCPAN -e shell install Coro
For more information on module installation, please visit the detailed CPAN module installation guide.