in reply to Boolean Thread::Semaphore ?
Again, this is 'brain-dead' in that elementary uses of ->down() and ->up() will work, whereas other 'fancy' operations may break (e.g., $sema->down(2) would 'hang' because the 'boolean' semaphore would never be greater than 1).package Thread::Semaphore::Boolean; use threads::shared; use parent 'Thread::Semaphore'; # Create a new 'boolean' semaphore sub new { my $class = shift; return $class->SUPER::new(1); } # Set semaphore's count to 1 sub up { my $sema = shift; lock($$sema); $$sema = 1; cond_broadcast($$sema); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Boolean Thread::Semaphore ?
by BrowserUk (Patriarch) on Feb 09, 2012 at 19:33 UTC | |
|
Re^2: Boolean Thread::Semaphore ?
by chrestomanci (Priest) on Feb 09, 2012 at 16:25 UTC |