in reply to Media Player - CPU Usage
You're using up 100% of one of the cores checking the conditions of the while loop as fast as possible. You need to sleep between checks.
while ('blah') { sleep 1; # in seconds select(undef,undef,undef, 0.1); # Or doze off for fractional seconds }
Should do. Adjust the numbers depending on how much CPU you want to spend vs how quickly you want to notice that the loop condition has changed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Media Player - CPU Usage
by roho (Bishop) on Nov 28, 2012 at 22:08 UTC |
In Section
Seekers of Perl Wisdom