Dev-Util
view release on metacpan or search on metacpan
examples/semaphore_test.pl view on Meta::CPAN
#!/usr/bin/env perl
use lib 'lib';
use Dev::Util::Syntax;
use Dev::Util::Sem qw(:all);
say <<"EOTEXT";
Run this program in two terminals simultaneously.
The second one started should wait until the first one
unlocks before it creates the semaphore.
EOTEXT
say "start";
my $sem = Dev::Util::Sem->new('thing.sem');
say "sem created";
say "go to sleep - 5 sec";
sleep 5;
say "wake up";
say "unlocking";
$sem->unlock;
say "unlocked";
say "end";
( run in 1.321 second using v1.01-cache-2.11-cpan-39bf76dae61 )