http://www.perlmonks.org?node_id=867104

perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:

I'm using a dynamically allocated queue, that I init with ||=, ala:
$PageQueue ||= Queue->new;
Since this is a 'test & set', and a typical location for a race condition, am I correct in assuming that this needs to be locked? during the test&set, like:
{ lock $PageQueue; $PageQueue ||= Queue->new; }
Thanks!