[Q] comment in SharedQueue>>peek

Colin Putney cputney at wiresong.ca
Sun Apr 3 15:34:34 UTC 2005


On Apr 3, 2005, at 9:24 AM, Boris Gaertner wrote:

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

Here's one:

In a stream context, the usual distinction between #next and #peek is 
that #next removes the object from the head of the stream, whereas 
#peek does not. The blocking behavior added by SharedQueue should be 
added uniformly to the stream protocol: since #next blocks the caller, 
#peek should as well. A non-blocking #peek may well be desirable but it 
should be called #peekOrNil to align with the other non-blocking 
methods in SharedQueue.

Colin




More information about the Squeak-dev mailing list