LOOP: while ( !$stat{'work'}{$t}{'stat'} ne 'done' ) {
{
lock %{ $stat{'lock'} };
$c = $listener->accept() or next LOOP;
}
notify( 'work', $t, 'busy' );
trc 'log', "new connect accept", $c->peerhost().":".$c->peerport();
# fix me, the thread blocks here, why?
# if I lock %{ $cnf{'lock'} } untill close the $c, things will be OK,
# but then we can't gain advantage of the multi-threads nor the pre-threads
# design.
if ( my $r = $c->get_request() ) {
####
# {
lock %{ $stat{'lock'} };
$c = $listener->accept() or next LOOP;
# }
####
sub do_worker {
my $t = threads->self()->tid();
# wait for the main thread finish initialization
# fix me, yield can't achieve our purpose, why?
# threads->yield();
sleep(1);