in reply to CPU Leaking Threads
Change the yield in your MainReaper thread to:
sleep 1 until ($DoneFlag || $Timeout);
Yield just relinguishes the rest of the threads timeslice. It immediately becomes eligible for rescheduling. That means that if no other thread is available to run, you've coded a very tight loop that will happily consume as much cpu as is available. By using a sleep, you will avoid thrashing the cpu. If you need finer than 1 second resolution, use Time::HiRes::sleep or the 4-arg select.
Note: This is based upon my observations of what happens on Win32. Your OS may work differently.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CPU Leaking Threads
by Trizor (Pilgrim) on Feb 21, 2007 at 22:43 UTC | |
by BrowserUk (Patriarch) on Feb 22, 2007 at 10:34 UTC | |
by Trizor (Pilgrim) on Feb 22, 2007 at 13:22 UTC |