I am having problems mixing the Thread::Pool and Event modules. I can access the a pool created outside of a callback, but can't create a pool within the callback. You can see it by running the program below with and without the argument 'out'.
Please help, -gr
#!perl use Thread::Pool; use Event; $Event::DebugLevel = 5;
my $var; my $pool;
pool() if $ARGV[0] eq 'out';
my $timer = Event->timer( desc => 'pool_test', at => time + 3, cb => \&callback );
Event::loop;
sub pool {
$pool = Thread::Pool->new(
{
do => sub {$var++}
}
) unless defined $pool;
return $pool;
}sub callback {
my $pool = pool();
my $id = $pool->job();
my $result = $pool->result($id);
print "var is: ", $result, "\n";
}