Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
laziness, impatience, and hubris
 
PerlMonks  

Re: Implement Queue mechanism in Perl

by BrowserUk (Pope)
on Jan 11, 2011 at 07:15 UTC ( #881610=note: print w/ replies, xml ) Need Help??


in reply to Implement Queue mechanism in Perl

#! perl -slw use strict; use Time::HiRes qw[ sleep ]; use threads; use threads::shared; my @commands = map { my $t = 2+int( rand 5 ); qq[ perl -E"sleep 1 while ++\$n < $t" ]; } 1 .. 300; my $running :shared = 0; my $done :shared = 0; for my $cmd ( @commands ) { async{ ++$running; system $cmd; --$running; ++$done; }->detach; printf( "\r$done, $running" ), sleep 0.1 while $running > 2; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Implement Queue mechanism in Perl
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881610]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-04-16 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (413 votes), past polls