[Chicago-talk] Fw: What problems do threads solve for you and how could your languagemake it easier

Michael Potter michael at potter.name
Tue Nov 2 09:58:16 PDT 2010


Here is how I would use parallel features in Perl....


sub myfunc1()
{
   # do some long running thing here.
}

sub myfunc2()
{
   # do another long running thing (perhaps a db query)
}

runthese(\&myfunc1, \&myfunc2)


Keeps it simple.
myfunc1() and myfunc2() run in parallel.
When the both finish runthese() returns.

runthese() should be able to be called from within a function that was
invoked with runthese().
runthese should return an array of the return codes from the myfuncN().
runthese should be able to take any reasonable number of arguments, or
perhaps an array of function pointers.

Some scheme should be developed such that the functions can read from the
same file or socket with some guarantee that they will not read the same
data.  Perhaps a specifier on a function that would tell perl to only allow
one instance of that function to run at a time.

-- 
Michael Potter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20101102/c8ebecf5/attachment.html>


More information about the Chicago-talk mailing list