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