author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 14:28:51 +0200 | |
changeset 5050 | 44fa8672d102 |
parent 4943 | e8327124ac63 |
permissions | -rw-r--r-- |
4943 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1307 | 3 |
" |
4 |
COPYRIGHT (c) 2000 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
929 | 14 |
"{ Package: 'stx:libbasic2' }" |
15 |
||
4368 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
18 |
Object subclass:#OperationQueue |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
19 |
instanceVariableNames:'queue queueLock consumerProcess consumerProcessPriority' |
929 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Kernel-Processes' |
|
23 |
! |
|
24 |
||
25 |
Object subclass:#OperationInQueue |
|
956 | 26 |
instanceVariableNames:'operation operationPerformedSema operationResult exception' |
929 | 27 |
classVariableNames:'' |
28 |
poolDictionaries:'' |
|
29 |
privateIn:OperationQueue |
|
30 |
! |
|
31 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
32 |
!OperationQueue class methodsFor:'documentation'! |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
33 |
|
1307 | 34 |
copyright |
35 |
" |
|
36 |
COPYRIGHT (c) 2000 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
48 |
documentation |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
49 |
" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
50 |
An operationQueue allows operations (i.e. actions) to be evaluated in |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
51 |
a first-come-first-serve queue like fashion. A single consumer process |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
52 |
waits for orders to be enqueued and evaluates them (as they come). |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
53 |
Producer processes which want to have some operation performed may |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
54 |
enqueue these. Producers are suspended, until the operation is finished. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
55 |
If multiple orders which compare equal are enqueued by multiple producers, |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
56 |
the operation is only evaluated once, and both producers will wake up when |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
57 |
the operation has finished. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
58 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
59 |
[author:] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
60 |
Martin Walser |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
61 |
Claus Gittinger |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
62 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
63 |
[see also:] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
64 |
SharedQueue |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
65 |
Queue |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
66 |
" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
67 |
! |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
68 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
69 |
examples |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
70 |
" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
71 |
two orders; done sequentially: |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
72 |
[exBegin] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
73 |
|opQ| |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
74 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
75 |
opQ := OperationQueue new. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
76 |
opQ scheduleOperation:[ Transcript showCR:'hello world-1']. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
77 |
opQ scheduleOperation:[ Transcript showCR:'hello world-2']. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
78 |
[exBegin] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
79 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
80 |
only 10 outputs (same operation entered by multiple producers): |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
81 |
[exBegin] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
82 |
|p1 p2 p3 opQ order| |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
83 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
84 |
opQ := OperationQueue new. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
85 |
order := [ Transcript showCR:'hello world ']. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
86 |
p1 := [ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
87 |
1 to:10 do:[:i | |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
88 |
opQ scheduleOperation:order. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
89 |
] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
90 |
] fork. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
91 |
p2 := [ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
92 |
1 to:10 do:[:i | |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
93 |
opQ scheduleOperation:order. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
94 |
] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
95 |
] fork. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
96 |
p3 := [ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
97 |
1 to:10 do:[:i | |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
98 |
opQ scheduleOperation:order. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
99 |
] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
100 |
] fork. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
101 |
[exBegin] |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
102 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
103 |
" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
104 |
! ! |
929 | 105 |
|
106 |
!OperationQueue class methodsFor:'instance creation'! |
|
107 |
||
108 |
new |
|
109 |
^ super new initializeLock |
|
110 |
! |
|
111 |
||
112 |
new:n |
|
113 |
^ (super new:n) initializeLock |
|
114 |
! ! |
|
115 |
||
116 |
!OperationQueue methodsFor:'accessing'! |
|
117 |
||
118 |
consumerProcess |
|
119 |
"return the value of the instance variable 'consumerProcess' (automatically generated)" |
|
120 |
||
121 |
^ consumerProcess |
|
122 |
! |
|
123 |
||
124 |
consumerProcessPriority |
|
125 |
"return the value of the instance variable 'consumerProcessPriority' (automatically generated)" |
|
126 |
||
127 |
^ consumerProcessPriority |
|
128 |
! |
|
129 |
||
130 |
consumerProcessPriority:something |
|
131 |
"set the value of the instance variable 'consumerProcessPriority' (automatically generated)" |
|
132 |
||
133 |
consumerProcessPriority := something. |
|
134 |
! ! |
|
135 |
||
136 |
!OperationQueue methodsFor:'consumer'! |
|
137 |
||
138 |
fetchNextOperationAndExecute |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
139 |
"dequeue the next order, evaluate it and wake up waiters" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
140 |
|
929 | 141 |
|opInQ theOperation rslt| |
142 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
143 |
opInQ := queue next. |
929 | 144 |
|
145 |
theOperation := opInQ operation. |
|
2994 | 146 |
AbortOperationRequest handle:[:ex | |
956 | 147 |
Transcript showCR:'operation aborted'. |
937 | 148 |
opInQ operationResult:nil. |
149 |
] do:[ |
|
2994 | 150 |
Error handle:[:ex | |
956 | 151 |
|ex2| |
152 |
||
153 |
Transcript showCR:'operation error: ', ex errorString. |
|
154 |
||
155 |
ex2 := ex shallowCopy. |
|
156 |
ex2 suspendedContext:(self copyContextChain:ex suspendedContext). |
|
157 |
opInQ exception:ex2. |
|
937 | 158 |
opInQ operationResult:nil. |
159 |
] do:[ |
|
160 |
rslt := theOperation value. |
|
161 |
]. |
|
162 |
]. |
|
929 | 163 |
opInQ operationResult:rslt. |
164 |
||
4943 | 165 |
opInQ operationPerformedSema signal. |
929 | 166 |
|
167 |
[ |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
168 |
queue isEmpty ifTrue:[ |
929 | 169 |
self stopConsumerProcess |
170 |
] |
|
171 |
] valueUninterruptably |
|
4943 | 172 |
|
173 |
"Modified: / 16-05-2019 / 14:52:55 / Stefan Vogel" |
|
929 | 174 |
! |
175 |
||
176 |
startConsumerProcess |
|
177 |
[ |
|
178 |
consumerProcess isNil ifTrue:[ |
|
179 |
consumerProcessPriority := consumerProcessPriority ? (Processor userSchedulingPriority). |
|
180 |
consumerProcess := [ |
|
181 |
[true] whileTrue:[ |
|
182 |
self fetchNextOperationAndExecute. |
|
183 |
]. |
|
184 |
] newProcess. |
|
185 |
consumerProcess priority:consumerProcessPriority. |
|
186 |
consumerProcess name:'Op-Q consumer'. |
|
187 |
consumerProcess resume. |
|
188 |
]. |
|
189 |
] valueUninterruptably |
|
190 |
! |
|
191 |
||
192 |
stopConsumerProcess |
|
193 |
[ |
|
194 |
|p| |
|
195 |
||
196 |
(p := consumerProcess) notNil ifTrue:[ |
|
197 |
consumerProcess := nil. |
|
198 |
p terminate |
|
199 |
]. |
|
200 |
] valueUninterruptably |
|
201 |
! ! |
|
202 |
||
956 | 203 |
!OperationQueue methodsFor:'debugging support'! |
204 |
||
205 |
copyContextChain:aContext |
|
206 |
"dequeue the next order, evaluate it and wake up waiters" |
|
207 |
||
208 |
|copy| |
|
209 |
||
210 |
copy := aContext shallowCopy. |
|
211 |
aContext sender notNil ifTrue:[ |
|
212 |
copy setSender:(self copyContextChain:aContext sender) |
|
213 |
]. |
|
214 |
^ copy |
|
215 |
! |
|
216 |
||
217 |
linkContextChain:aConsumerChain |
|
218 |
"for debugging - concatenate aConsumerChain to my own context chain (to make debugging easier)" |
|
219 |
||
220 |
|c| |
|
221 |
||
222 |
c := aConsumerChain. |
|
2974 | 223 |
[c sender notNil and:[c methodSelector ~~ #fetchNextOperationAndExecute]] whileTrue:[ |
956 | 224 |
c := c sender. |
225 |
]. |
|
226 |
c setSender:(thisContext sender). |
|
227 |
! ! |
|
228 |
||
929 | 229 |
!OperationQueue methodsFor:'initialization'! |
230 |
||
231 |
initializeLock |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
232 |
queue := SharedQueue new. |
929 | 233 |
queueLock := Semaphore forMutualExclusion. |
234 |
! ! |
|
235 |
||
236 |
!OperationQueue methodsFor:'producer'! |
|
237 |
||
238 |
scheduleOperation:anotherOperation |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
239 |
"enqueue an order (something that understands #value) to the op-queue; |
929 | 240 |
wait until the operation has performed (#value been sent), |
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
241 |
return the result of the #value send. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
242 |
If a similar order is already in the queue, wait for that one to finish." |
929 | 243 |
|
935 | 244 |
^ self scheduleOperation:anotherOperation asynchronous:false |
245 |
! |
|
246 |
||
247 |
scheduleOperation:anotherOperation asynchronous:asynchronous |
|
248 |
"enqueue an order (something that understands #value) to the op-queue; |
|
249 |
if asynchronous is false, wait until the operation has performed (#value been sent), |
|
250 |
return the result of the #value send. |
|
251 |
If a similar order is already in the queue, wait for that one to finish. |
|
252 |
If asynchronous is true, do not wait (but also: do not return a return value)" |
|
253 |
||
956 | 254 |
|myOpInQ ex| |
929 | 255 |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
256 |
queueLock critical:[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
257 |
"/ operation already in queue ? |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
258 |
queue withAccessLockedDo:[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
259 |
myOpInQ := nil. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
260 |
queue do:[:eachOpInQ | |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
261 |
anotherOperation = eachOpInQ operation ifTrue:[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
262 |
myOpInQ := eachOpInQ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
263 |
] |
929 | 264 |
]. |
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
265 |
"/ if not, create a new one and enqueue |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
266 |
myOpInQ isNil ifTrue:[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
267 |
myOpInQ := OperationInQueue new. |
4943 | 268 |
"/ use an EventSemaphore to protect against races between signal and wait |
269 |
myOpInQ operationPerformedSema:(EventSemaphore new). |
|
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
270 |
myOpInQ operation:anotherOperation. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
271 |
[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
272 |
queue nextPut:myOpInQ. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
273 |
consumerProcess isNil ifTrue:[ |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
274 |
self startConsumerProcess |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
275 |
]. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
276 |
] valueUninterruptably. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
277 |
]. |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
278 |
]. |
4368 | 279 |
]. |
929 | 280 |
|
935 | 281 |
asynchronous ifTrue:[ |
282 |
^ nil |
|
283 |
]. |
|
284 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
285 |
"/ wait for the operation to finish |
929 | 286 |
myOpInQ operationPerformedSema wait. |
956 | 287 |
(ex := myOpInQ exception) notNil ifTrue:[ |
288 |
"/ trick: makes calling chain look as if the error happended here |
|
289 |
"/ (in reality, it happended in the consumer-process). |
|
290 |
self linkContextChain:ex suspendedContext. |
|
929 | 291 |
|
4368 | 292 |
^ ex creator raiseErrorString:('asynchronous operation error:' , ex errorString) in:ex suspendedContext |
956 | 293 |
]. |
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
294 |
"/ now, the operation has been performed - return its result |
929 | 295 |
^ myOpInQ operationResult |
4368 | 296 |
|
297 |
"Modified (format): / 22-05-2017 / 12:08:05 / mawalch" |
|
4943 | 298 |
"Modified: / 16-05-2019 / 14:51:57 / Stefan Vogel" |
929 | 299 |
! ! |
300 |
||
930
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
301 |
!OperationQueue methodsFor:'queries'! |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
302 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
303 |
size |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
304 |
"return the number of operations in the queue" |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
305 |
|
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
306 |
^ queue size |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
307 |
! ! |
f084913b188a
rewritten to no longer be a subclass of sharedQueue
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
308 |
|
929 | 309 |
!OperationQueue::OperationInQueue methodsFor:'accessing'! |
310 |
||
956 | 311 |
exception |
312 |
"return the value of the instance variable 'exception' (automatically generated)" |
|
313 |
||
314 |
^ exception |
|
315 |
! |
|
316 |
||
317 |
exception:something |
|
318 |
"set the value of the instance variable 'exception' (automatically generated)" |
|
319 |
||
320 |
exception := something. |
|
321 |
! |
|
322 |
||
929 | 323 |
operation |
324 |
"return the value of the instance variable 'operation' (automatically generated)" |
|
325 |
||
326 |
^ operation |
|
327 |
! |
|
328 |
||
329 |
operation:something |
|
330 |
"set the value of the instance variable 'operation' (automatically generated)" |
|
331 |
||
332 |
operation := something. |
|
333 |
! |
|
334 |
||
335 |
operationPerformedSema |
|
336 |
"return the value of the instance variable 'operationPerformedSema' (automatically generated)" |
|
337 |
||
338 |
^ operationPerformedSema |
|
339 |
! |
|
340 |
||
341 |
operationPerformedSema:something |
|
342 |
"set the value of the instance variable 'operationPerformedSema' (automatically generated)" |
|
343 |
||
344 |
operationPerformedSema := something. |
|
345 |
! |
|
346 |
||
347 |
operationResult |
|
348 |
"return the value of the instance variable 'operationResult' (automatically generated)" |
|
349 |
||
350 |
^ operationResult |
|
351 |
! |
|
352 |
||
353 |
operationResult:something |
|
354 |
"set the value of the instance variable 'operationResult' (automatically generated)" |
|
355 |
||
356 |
operationResult := something. |
|
357 |
! ! |
|
358 |
||
359 |
!OperationQueue class methodsFor:'documentation'! |
|
360 |
||
361 |
version |
|
4368 | 362 |
^ '$Header$' |
929 | 363 |
! ! |
2974 | 364 |