- or download this
if ( my $thread = threads->new( \&do_worker ) ) {
my $t = $thread->tid;
lock %{ $stat{'work'} };
$stat{'work'}{ $t } = &share( {} );
$stat{'work'}{ $t }{'stat'} = 'idle';
- or download this
sub do_worker {
my $t = threads->self()->tid();
# sleep(1);
my $c;
LOOP: while ( !$stat{'work'}{$t}{'stat'} ne 'done' ) {
- or download this
sub do_worker {
my $t = threads->self()->tid();
...
trc 'dbg', 'new worker created';
$thread->detach;
...
- or download this
LOOP: while ( $stat{'work'}{$t}{'stat'} ne 'done' ) {
{
lock %{ $stat{'lock'} };
$c = $listener->accept() or next LOOP;
}
- or download this
timeout => 10,</code>.
<P>If you remove the <c>sleep 1;
- or download this
lock %{ $stat{'work'} };
...
$stat{'work'}{$t}{'stat'} = $s;
$stat{'work'}{$t}{'time'} = time();
$stat{'work'}{$t}{'work'}++ if $s eq 'idle';
- or download this
lock %{ $stat{'work'}{$t} };
...
$stat{'work'}{$t}{'stat'} = $s;
$stat{'work'}{$t}{'time'} = time();
$stat{'work'}{$t}{'work'}++ if $s eq 'idle';