You don't want a semaphore.
The simplest mechanism is:
while( my $workitem = sourceOfWork() ) { sleep 1 while $Q->pending > MAXQ; $Q->enqueue( $workitem ); }
Thanks, that looks to be a much more sensible approach compared with what I was doing with semaphores.
That should teach me to read algorithoms online that are intened for other languages or problem domains where near realtime responses are required.
In reply to Re^2: Boolean Thread::Semaphore ?
by chrestomanci
in thread Boolean Thread::Semaphore ?
by chrestomanci
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |