I was parsing through some documentation from the old Thread.pm (Perl
5.6), and noticed the following:

"join
    join waits for a thread to end and returns any values the thread
exited with. join will block until the thread has ended, though it
won't block if the thread has already terminated.

    If the thread being joined died, the error it died with will be
returned at this time. If you don't want the thread performing the join
to die as well, you should either wrap the join in an eval or use the
eval thread method instead of join.

eval
    The eval method wraps an eval around a join, and so waits for a
thread to exit, passing along any values the thread might have
returned. Errors, of course, get placed into [EMAIL PROTECTED]"


Is there any reason this does not exist in modern ithreads?  Being able
to detect the reason why a thread existed during join could be
extremely useful.  As it is, I currently use a kludgy method (by
trapping die and making it available via a shared datastructure) in
some application to make a best guess as to the reason behind
terminated threads.

Would there be interest in re-adding it?  Perhaps, to keep consistent
behavior, $thr->join() could act like the old Thread.pm $thr->eval(),
and a new method, $thr->join_noeval() could be added?

Or, perhaps to be _really_ consistent with current ithread behavior
(join has no affect on the value of $@), but add two new methods:
 $thr->join_eval()   # join and propegate $@ from thread, if defined
 $thr->join_noeval() # join and die with value of $@ from thread, if
defined

Regards,
Eric

Reply via email to