in reply to grand central dispatch like mechanism?

No. But it is trivial to write your own:

#! perl -slw use strict; use threads; sub grandCentral { my @t = map threads->create( $_ ), @_; return map $_->join, @t; } sub runme { my $arg = shift; sleep $arg * 2; return $arg; } sub a{ runme( 1 ) } sub b{ runme( 2 ) } sub c{ runme( 3 ) } sub d{ runme( 4 ) } my $start = time; my @results = grandCentral( \&a, \&b, \&c, \&d ); print for @results; printf "Took %d seconds\n", time - $start; __END__ C:\test>centralDispatch.pl 1 2 3 4 Took 8 seconds

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.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: grand central dispatch like mechanism?
by iaw4 (Monk) on Feb 18, 2010 at 01:37 UTC
    thanks, superdoc. this is 95% of the functionality. the other 5% is intelligent queuing---with 2 processors, first run 2 processes, then run the next 2 processes...
      this is 95% of the functionality. the other 5% is intelligent queuing-

      No. That code will be intelligently dispatched by the OS kernel scheduler. As coded, it will still only take 8 seconds to run even if you only have a single processor.

      It is really hard to explain how it does that if you do not understand Timeslicing & Preemptive Multitasking, but trust me, it works.


      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.