[Q] Has SharedQueue a very subtle bug?

Hans-Martin Mosner hmm at heeg.de
Mon Apr 29 18:28:44 UTC 2002


goran.hultgren at bluefish.se wrote:

> PS. This thread talks about plenty of problems and solutions to the
> SharedQueue class. Someone (perhaps me being a harvester) should sit
> down and try to rewrite it so that it actually works. DS

The actual problem is only that the #next method signals an error when it
finds that after waiting on readSynch, there is no element in the queue. This
can easily be fixed by turning it into a loop which repeatedly waits on
readSynch and tries to get an object out of the queue until it succeeds. In
addition, all other methods accessing contentsArray, readPosition and
writePosition should use accessProtect to avoid race conditions.
Attached find a change set implementing just these changes. To be a good boy,
I also updated the class comment and documented the instance variables.
Please check this implementation and see whether you find any weaknesses
(apart from processes being brutally terminated in the middle of protected
code...).

Cheers,
Hans-Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SharedQueueFix.1.cs.gz
Type: application/octet-stream
Size: 1317 bytes
Desc: Unknown Document
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020429/5fb485ad/SharedQueueFix.1.cs.obj


More information about the Squeak-dev mailing list