[Q] Has SharedQueue a very subtle bug?

Lex Spoon lex at cc.gatech.edu
Mon Apr 29 04:17:34 UTC 2002


goran.hultgren at bluefish.se wrote:
> Scott A Crosby <crosby at qwes.math.cmu.edu> wrote:


> > So the options are either this idiom:
> > 
> >     sq critical: [ ..... sq isEmpty ....]
> >     sq critical: [ ..... sq size ....]
> > 
> > Or this idiom
> > 
> >     sq ifEmpty: [ ........ ]
> >     sq withSize: [ :size |  ...... ]
> > 
> > In either case, it is not permitted to do queue mutation during those
> 
> 
> > blocks. (Until/unless squeak gets reentrant locks.)
> 
> Well, that would only fix half of the problem I think. You must also
> change the current situation where other readers can be queued up. But
> sure.

[ and on and on ]


#nextOrNil is pretty good.  It checks whether something is there, and it
removes it for you if there is.  It avoids race conditions and it's
really simple to reason about.  If it returns nil, then #isEmpty was
true.  If something is there, then you've got it with no further
question.


Lex



More information about the Squeak-dev mailing list