Help for this page

Select Code to Download


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