On Fri, Jun 15, 2007 at 03:07:31PM -0300, Roberto Etcheverry wrote:
> I forgot to send you to minimum perl script that exhibits the problem.

> #!/usr/bin/perl 
> use strict;
> use warnings;
> 
> use threads;
> use Event;
> 
> sub create_thread {
>     warn "in create_thread() before async()\n";
>     my $thr = async { warn "in thread\n"; };
>     warn "in create_thread() before join()\n";
>     sleep 2;
>     $thr->join;
>     warn "in create_thread() before return\n";
>     return;
> }
> 
> 
> my $timer = Event->timer( cb => \&create_thread, after => 2);
> 
> warn "starting event loop\n";
> Event::loop;

I don't think you can create a thread inside an event handler because of 
the way Event abuses perl data structures. What I suggest is to create a 
thread outside of event and pass messages to the thread using a 
threadsafe queue or similar.

-- 
Make April 15 just another day, visit http://fairtax.org

Reply via email to