I once enjoyed browsing through the articles on PerlMonks. What isn't fun is the rudeness towards other monks. Why the rudeness? But maybe, ikegami was rude in his response to your demonstration.
The interesting thing is that BrowserUk's demonstration runs with the lock obtained outside the while loop. This is also true on the Windows platform.
sub set_positive { lock $a; while (1) { ... } } sub set_zero { lock $a; while (1) { ... } }
A long time monk ikegami made a correct statement when stating the lock is re-obtained before cond_wait returns. In fact, that is mentioned in the threads::shared documentation.
Another finding is the printer output containing "0 0" indicating set_zero enqueued twice in a row. Also, the output contains two positives indicating set_positive enqueued twice in a row. These occur often in the output. The OP does not mention if such occurrence is valid, so am not sure.
Is there a code of conduct for PerlMonks? The reason is that there is no joy in seeing monks attacking one another. Recently, the Mojolicious team added a section titled Code Of Conduct to a guide. Is there anything like that for PerlMonks?
In reply to Re^10: Threads sharing global variable (disingenous)
by Anonymous Monk
in thread Threads sharing global variable
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |