bucky0 has asked for the wisdom of the Perl Monks concerning the following question:
This is a grossly simplified example, but it should show the problem. If the cond_signal is reached before the other thread reaches the cond_wait, the signal is discarded and the cond_wait will block forever.use strict; use warnings; # hallelujah use threads; use threads::shared; # threads, oh how I hate my $lockvar : shared = 0; my $thrHandle = threads->create( &exampleSub ); {lock $lockvar; cond_wait ($lockvar);} # code that should be executed at the same time as the # block below $thrHandle->join(); sub exampleSub { # some initialisation which may, or may not, take a lot # of time {lock $lockvar; cond_signal( $lockvar );} # code that should be executed at the same time as the # block above }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Blocking cond_signal until someone cond_waits
by dave_the_m (Monsignor) on Dec 19, 2006 at 19:33 UTC | |
|
Re: Blocking cond_signal until someone cond_waits
by BrowserUk (Patriarch) on Dec 19, 2006 at 18:12 UTC | |
by bucky0 (Initiate) on Dec 19, 2006 at 18:16 UTC |