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