equal
deleted
inserted
replaced
131 super remove:anElement ifAbsent:[noSuchElement := true] |
131 super remove:anElement ifAbsent:[noSuchElement := true] |
132 ]. |
132 ]. |
133 noSuchElement ifTrue:[ |
133 noSuchElement ifTrue:[ |
134 ^ exceptionalValue value. |
134 ^ exceptionalValue value. |
135 ]. |
135 ]. |
|
136 dataAvailable consume. |
136 spaceAvailable signal. |
137 spaceAvailable signal. |
137 ^ retVal. |
138 ^ retVal. |
138 |
139 |
139 "Created: / 22-02-2017 / 14:53:13 / stefan" |
140 "Created: / 22-02-2017 / 14:53:13 / stefan" |
|
141 "Modified: / 22-02-2017 / 16:50:49 / stefan" |
140 ! |
142 ! |
141 |
143 |
142 removeAll |
144 removeAll |
143 "remove all elements in the queue; do not wait, but |
145 "remove all elements in the queue; do not wait, but |
144 synchronize access to the queue. |
146 synchronize access to the queue. |
160 |
162 |
161 removeIdentical:anElement ifAbsent:exceptionalValue |
163 removeIdentical:anElement ifAbsent:exceptionalValue |
162 |retVal noSuchElement| |
164 |retVal noSuchElement| |
163 |
165 |
164 noSuchElement := false. |
166 noSuchElement := false. |
165 retVal := accessLock critical:[ |
167 accessLock critical:[ |
166 super removeIdentical:anElement ifAbsent:[noSuchElement := true] |
168 retVal := super removeIdentical:anElement ifAbsent:[noSuchElement := true]. |
|
169 noSuchElement ifFalse:[ |
|
170 dataAvailable consume. |
|
171 ]. |
167 ]. |
172 ]. |
168 noSuchElement ifTrue:[ |
173 noSuchElement ifTrue:[ |
169 ^ exceptionalValue value. |
174 ^ exceptionalValue value. |
170 ]. |
175 ]. |
171 spaceAvailable signal. |
176 spaceAvailable signal. |
172 ^ retVal. |
177 ^ retVal. |
173 |
178 |
174 "Modified: / 22-02-2017 / 14:39:40 / stefan" |
179 "Modified: / 22-02-2017 / 17:05:10 / stefan" |
175 ! |
180 ! |
176 |
181 |
177 removeLast |
182 removeLast |
178 "return the last value in the queue; if it its empty, wait until |
183 "return the last value in the queue; if it its empty, wait until |
179 something is put into the receiver. |
184 something is put into the receiver. |
186 retVal := accessLock critical:[super removeLast]. |
191 retVal := accessLock critical:[super removeLast]. |
187 spaceAvailable signal. |
192 spaceAvailable signal. |
188 |
193 |
189 ^ retVal. |
194 ^ retVal. |
190 |
195 |
191 "Modified: / 22-02-2017 / 14:40:02 / stefan" |
196 "Modified: / 22-02-2017 / 16:50:39 / stefan" |
192 ! ! |
197 ! ! |
193 |
198 |
194 !SharedQueue methodsFor:'accessing-internals'! |
199 !SharedQueue methodsFor:'accessing-internals'! |
195 |
200 |
196 accessLock |
201 accessLock |
215 ! |
220 ! |
216 |
221 |
217 superNextPut:anObject |
222 superNextPut:anObject |
218 "private; to allow subclasses to call the basic nextPut (w.o. synchronization)" |
223 "private; to allow subclasses to call the basic nextPut (w.o. synchronization)" |
219 |
224 |
220 ^ super nextPut:anObject. |
225 super nextPut:anObject. |
|
226 |
|
227 "Modified: / 22-02-2017 / 16:34:11 / stefan" |
221 ! |
228 ! |
222 |
229 |
223 superNextPutFirst:anObject |
230 superNextPutFirst:anObject |
224 "private; to allow subclasses to call the basic nextPutFirst (w.o. synchronization)" |
231 "private; to allow subclasses to call the basic nextPutFirst (w.o. synchronization)" |
225 |
232 |
226 ^ super nextPutFirst:anObject. |
233 super nextPutFirst:anObject. |
|
234 |
|
235 "Modified: / 22-02-2017 / 16:34:16 / stefan" |
227 ! |
236 ! |
228 |
237 |
229 withAccessLockedDo:aBlock |
238 withAccessLockedDo:aBlock |
230 "evaluate aBlock while access via next/nextPut are blocked." |
239 "evaluate aBlock while access via next/nextPut are blocked." |
231 |
240 |
268 |retVal isEmpty| |
277 |retVal isEmpty| |
269 |
278 |
270 retVal := accessLock critical:[ |
279 retVal := accessLock critical:[ |
271 isEmpty := self isEmpty. |
280 isEmpty := self isEmpty. |
272 isEmpty ifFalse:[ |
281 isEmpty ifFalse:[ |
|
282 dataAvailable consume. |
273 super nextOrNil |
283 super nextOrNil |
274 ]. |
284 ]. |
275 ]. |
285 ]. |
276 isEmpty ifTrue:[ |
286 isEmpty ifTrue:[ |
277 ^ exceptionBlock value |
287 ^ exceptionBlock value |
278 ]. |
288 ]. |
279 spaceAvailable signal. |
289 spaceAvailable signal. |
280 ^ retVal. |
290 ^ retVal. |
281 |
291 |
282 "Modified (comment): / 22-02-2017 / 15:29:30 / stefan" |
292 "Modified: / 22-02-2017 / 17:03:23 / stefan" |
283 ! |
293 ! |
284 |
294 |
285 nextOrNil |
295 nextOrNil |
286 ^ self nextIfEmpty:nil |
296 ^ self nextIfEmpty:nil |
287 |
297 |