[Q] comment in SharedQueue>>peek

Boris Gaertner Boris.Gaertner at gmx.net
Sun Apr 3 13:24:33 UTC 2005


This question relates to Squeak 3.7.

In the instance method  peek  of  SharedQueue we read
this:

"Answer the object that was sent through the receiver first and has not 
 yet been received by anyone but do not remove it from the receiver. If 
 no object has been sent, suspend the requesting process until one is."

The last sentence is wrong. What really happens is that peek
returns immediately with  nil  if no object has  been sent.
This is clear from the very understandable code, but it can
also demonstrated with this code snippet:

 | sq |
 sq := SharedQueue new.
 sq peek 

A quick look through earlier versions of Squeak (back to 2.3)
reveals that this method has not been changed since Squeak 2.3
and there is reason to believe that it was in fact never changed.

SharedQueue>>peek is sent in  EventSensor>>peekEvent.


I think that the comment of the method is wrong (it was credibly
simply copied from  SharedQueue>>next) and should be fixed.
I do not think that the method itself is wrong, but my question is:

Are there arguments in favour of a peek that suspends the requestor
until an item is put into a shared queue?

Your advice will be appreciated.

Greetings,
Boris







More information about the Squeak-dev mailing list