The semaphores provided with perl's threading modules should provide a nicer solution than sleep 1 while $count.
| [reply] [d/l] |
Why write 30 lines of complicated code when one is just about perfect.
sleep causes the sleeping thread to relinguish its timeslice(s) until the sleep times out, which means almost no load.
The semaphores api (like the rest of the pthreads api that perls threads are modelled on), is under specified, messy and hard to get right.
The sleep 1 while $count; is easy to code, easy to understand and "just works" :)
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] [d/l] |
sleep 1 while $count; # Or use Thread::Semaphore
so that people who don't know about threads wouldn't think that's the only way. I guess I should have been more polite or something... =)
| [reply] [d/l] |