in reply to Re^9: Proper undefine queue with multithreads
in thread Proper undefine queue with multithreads

It's not locking long enough. There's a step by step demonstration of the race condition in the linked post.
  • Comment on Re^10: Proper undefine queue with multithreads

Replies are listed 'Best First'.
Re^11: Proper undefine queue with multithreads
by Anonymous Monk on Jun 07, 2014 at 09:08 UTC

    It's not locking long enough. There's a step by step demonstration of the race condition in the linked post.

    Maybe there is a chance of this occuring with sleep 0.01 but BrowserUk originally had sleeps of 1 -- I doubt this race condition could ever manifest with more than one worker .... esp when you're not using pending (like originally)... but even with the ops changed code and pending

    Isn't it simpler to just

    for( 1..10 ){ ## make sure we're not between DQ and $busy++ sleep 1; sleep 1 while $q->pending || $busy; }

    I can't quantify the odds exactly other than to say probably never

      I doubt this race condition could ever manifest with more than one worker

      It will either affect all workers (race condition occurred) or none (race condition didn't occur). It can't affect just one (unless there's a second race condition I didn't see).