I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-07-31 16:38:17.354361-07 by jdhedden in response to 12858
Re: block until one thread is joinable?
You asked: As a different request, I noticed that it would be nice to register (at thread create time) a callback function that is invoked to handle the result (in parent context) when join is called.

This can easily be done by creating a hash to register callbacks based on thread IDs:
my %callbacks; my $thr = threads->create(...); $callback{$thr->tid()} = \&callback;
Then wherever you monitor the thread termination queue, you get the ID of the completed thread and invoke the callback:
my $id = $q->dequeue(); $callback{$id}->($id);
The callback then joins with the thread and completes the work:
sub callback { my $id = $_[0]; my $thr = threads->object($id); my $result = $thr->join(); ... }
Direct Responses: Write a response