'From Squeakland-OLPC of 3 September 2008 [Letztes Update: #2126] on 5 September 2008 at 4:17:10 pm'! "Change Set: answerFlushed-bf Date: 5 September 2008 Author: Bert Freudenberg Make SharedQueue>flushAllSuchThat: answer the flushed elements"! !SharedQueue methodsFor: 'accessing' stamp: 'bf 9/5/2008 16:14'! flushAllSuchThat: aBlock "Remove from the queue all objects that satisfy aBlock, and answer them" | removed value newReadPos | removed := OrderedCollection new: self size. accessProtect critical: [ newReadPos _ writePosition. writePosition-1 to: readPosition by: -1 do: [:i | value _ contentsArray at: i. contentsArray at: i put: nil. (aBlock value: value) ifTrue: [ removed addFirst: value. "We take an element out of the queue, and therefore, we need to decrement the readSynch signals" readSynch wait. ] ifFalse: [ newReadPos _ newReadPos - 1. contentsArray at: newReadPos put: value]]. readPosition _ newReadPos]. ^removed ! !