On Wed, Jul 06, 2005 at 09:12:29AM -0400, Lihn, Steve wrote:
> It appears identical. I am not sure why I thought it is better.
> Sorry about it...

Hmm, its threads so appearing identical is not always identical.
If I had to guess the intention was to protect all of @$q from being
sucked away?  So that if something empties @$q you still have $p to return.

Best guess I can make not knowing much about Thread::Queue.


> > The original is like:
> > 
> > sub dequeue  {
> >     my $q = shift;
> >     lock(@$q);
> >     cond_wait @$q until @$q;
> >     cond_signal @$q if @$q > 1;
> >     return shift @$q;
> > }
> > 
> > Should it be safer if it goes like this?
> > 
> > sub dequeue  {
> >     my $q = shift;
> >     lock(@$q);
> >     cond_wait @$q until @$q;
> >     my $p = shift @$q;
> >     cond_signal @$q if @$q >= 1;
> >     return $p;
> > }


-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Just call me 'Moron Sugar'.
        http://www.somethingpositive.net/sp05182002.shtml

Reply via email to