in reply to Output Queue from Multiple Threads
The simplest solution to the memory growth problem is to bound the size of the queue in the writers:
use constant LIMIT => 1000; sub pause { my $delay = shift; select '','','', $delay; } sub workerSub { my ($workerQueue,$outputQueue) = @_; while (my $computer = $workerQueue->dequeue()) { ## SSH command retrieving grep results and processing pause( 0.01 ) while $outputQueue->pending > LIMIT; $outputQueue->enqueue($results); } }
For a slightly more sophisticated approach, take a look at my self-limiting queue implementation:threads::Q
Anyone got any experience of this phone's predecessor?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Output Queue from Multiple Threads
by bigbot (Beadle) on Jul 31, 2015 at 15:07 UTC | |
by BrowserUk (Patriarch) on Jul 31, 2015 at 17:50 UTC |