Next 4.2 Thread::Semaphore Prev

Thread::Semaphore

Semaphores provide a mechanism to regulate access to resources.

use Thread::Semaphore; my $s = new Thread::Semaphore; $s->up; # The guarded section is here $s->down;
Semaphores don't limit their values to zero or one, so they can be used to control access to some resource that there may be more than one of.
my $s = new Thread::Semaphore(6); # default is 1 $s->up(2); $s->down(1); $s->down(1);

Next Perl Threads Prev