in reply to Re^2: threads: spawn early to avoid the crush.
in thread threads: spawn early to avoid the crush.
I like this idea. A suggestion for the interface:
use threads::lite; my $factory = threads::line->new( -threads => 10 ); #reserve 10 thread +s my $x_thr = $factory->create( \&doX, \@Xargs, \%optional_configs ); my $y_thr = $factory->create( \&doY, \@Yargs );
The general ideas are
sub _default_thread { my $thr_id = shift; if (defined $s_coderef[$thr_id] && ref $s_coderef[$thr_id] eq 'CODE +') { $s_coderef[$thr_id]->(@{ $s_param[$thr_id] }); $s_coderef[$thr_id] = undef; } else { sleep(1) } }
This is just off the top of my head, so take it as such.
|
---|