author | Stefan Vogel <sv@exept.de> |
Thu, 11 Aug 2016 15:26:39 +0200 | |
changeset 20235 | 9e8a7ad991f0 |
parent 20118 | 6e87720add31 |
child 20244 | 20922299fd44 |
child 20993 | 95a1fa000736 |
permissions | -rw-r--r-- |
1 | 1 |
" |
20041 | 2 |
COPYRIGHT (c) 1993,2015 by Claus Gittinger |
3 |
All Rights Reserved |
|
1 | 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 |
" |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
4608
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
4608
diff
changeset
|
13 |
|
18788 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
20041 | 16 |
WeakIdentityDictionary subclass:#Registry |
17 |
instanceVariableNames:'' |
|
1286 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20041 | 20 |
category:'Collections-Weak' |
1 | 21 |
! |
22 |
||
1961 | 23 |
!Registry class methodsFor:'documentation'! |
1 | 24 |
|
88 | 25 |
copyright |
26 |
" |
|
20041 | 27 |
COPYRIGHT (c) 1993,2015 by Claus Gittinger |
28 |
All Rights Reserved |
|
88 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
1 | 39 |
documentation |
40 |
" |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
41 |
Registries provide an easy interface to using WeakArrays. |
69 | 42 |
A class, which wants to be informed of instance-death, can put a created object |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
43 |
into a registry. The registry will create an executor, which is a (shallow-)copy |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
44 |
of the object, and watch out for death of the original object. When it dies, |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
45 |
the executor will be sent a #finalize message. |
69 | 46 |
The trick with the shallow copy is especially nice, you can think of it as |
47 |
being the original object which died. |
|
1 | 48 |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
49 |
All objects, which keep external resources (such as fileDescriptors, fonts, |
69 | 50 |
colormap-entries etc.) should be registered, so that the underlying resource |
51 |
can be freed when the object goes away. |
|
1 | 52 |
|
69 | 53 |
Of course, you too can use it to do whatever you need to do in case of the |
54 |
death of an object. |
|
159 | 55 |
|
20118 | 56 |
Registries use #executor to acquire the copy of the original, |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
57 |
this can be redefined in individual classes for faster copying |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
58 |
(typically, not all internal state, but only some device handles are needed for |
14352 | 59 |
finalization). If the to-be-registered object is large, this method may also |
317 | 60 |
return a stub (placeHolder) object. (i.e. there is no need for the copy to be |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
61 |
of the same class as the original, as long as it implements #finalize and frees |
14352 | 62 |
the relevant OS resources. Some classes return a specialized private-class instance, |
63 |
which only holds on the handle and implements #finalize.) |
|
1286 | 64 |
Example uses are found in Form, Color, ExternalStream and Font |
159 | 65 |
|
1286 | 66 |
[author:] |
20041 | 67 |
Claus Gittinger |
1286 | 68 |
|
69 |
[see also:] |
|
20041 | 70 |
WeakArray WeakIdentityDictionary |
71 |
Font Form Color Cursor ExternalStream |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
72 |
|
1 | 73 |
" |
74 |
! ! |
|
75 |
||
76 |
!Registry methodsFor:'accessing'! |
|
77 |
||
78 |
contents |
|
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
79 |
"return the collection of registered objects. |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
80 |
Warning: this returns a weak collection." |
1 | 81 |
|
20041 | 82 |
^ self keys. |
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
83 |
! ! |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
84 |
|
20041 | 85 |
!Registry methodsFor:'element disposal'! |
86 |
||
87 |
clearDeadSlots |
|
88 |
|wasBlocked executors| |
|
89 |
||
90 |
" |
|
91 |
have to block here - dispose may be done at a low priority |
|
92 |
from the background finalizer. If new items are added by a |
|
93 |
higher prio process, the dictionary might get corrupted otherwise |
|
94 |
" |
|
95 |
wasBlocked := OperatingSystem blockInterrupts. |
|
96 |
[ |
|
97 |
keyArray |
|
98 |
forAllDeadIndicesDo:[:idx | |
|
99 |
executors isNil ifTrue:[ |
|
100 |
executors := OrderedCollection new. |
|
101 |
]. |
|
102 |
executors add:(valueArray basicAt:idx). |
|
103 |
valueArray basicAt:idx put:nil. |
|
104 |
tally := tally - 1. |
|
105 |
] |
|
106 |
replacingCorpsesWith:DeletedEntry. |
|
107 |
] ensure:[ |
|
108 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
109 |
executors notNil ifTrue:[ |
|
110 |
executors do:[:eachExecutor| |
|
111 |
[ |
|
112 |
self informDispose:eachExecutor. |
|
113 |
] on:Error do:[:ex| |
|
114 |
Logger error:'Error %1 during finalization of: %2' with:ex description with:eachExecutor. |
|
115 |
ex suspendedContext fullPrintAllLevels:10. |
|
116 |
]. |
|
117 |
]. |
|
118 |
]. |
|
119 |
]. |
|
120 |
! |
|
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
121 |
|
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
122 |
informDispose:someHandle |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
123 |
"send a dispose message - this is sent to the executor, |
2181 | 124 |
since the original is already gone" |
125 |
||
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
126 |
someHandle finalize |
1 | 127 |
! |
128 |
||
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
129 |
update:something with:aParameter from:changedObject |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
130 |
"an instance has been destroyed - look which one it was" |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
131 |
|
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
132 |
something == #ElementExpired ifTrue:[ |
20041 | 133 |
self clearDeadSlots. |
134 |
^ self. |
|
2181 | 135 |
]. |
20041 | 136 |
something == #earlyRestart ifTrue:[ |
137 |
self removeAll. |
|
138 |
]. |
|
139 |
super update:something with:aParameter from:changedObject. |
|
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
140 |
|
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
141 |
"Created: 15.6.1996 / 15:24:41 / cg" |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
142 |
"Modified: 8.1.1997 / 14:05:02 / stefan" |
2669
7cf9ba3c7817
care for size changes while handling dispose-updates
Claus Gittinger <cg@exept.de>
parents:
2557
diff
changeset
|
143 |
"Modified: 2.6.1997 / 18:15:23 / cg" |
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
144 |
! ! |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
145 |
|
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
146 |
!Registry methodsFor:'enumerating'! |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
147 |
|
15007 | 148 |
detect:aBlock ifNone:exceptionValue |
20041 | 149 |
keyArray validElementsDo:[:obj | |
150 |
(obj ~~ DeletedEntry and:[aBlock value:obj]) ifTrue:[^ obj]. |
|
15007 | 151 |
]. |
152 |
^ exceptionValue value |
|
153 |
! |
|
154 |
||
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
155 |
do:aBlock |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
156 |
"evaluate aBlock for each registered object" |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
157 |
|
20041 | 158 |
"#keysDo: would not work, since the keyArray instvar may change if |
159 |
elements are unregistered while looping." |
|
160 |
||
161 |
^ keyArray validElementsDo:[:each| |
|
162 |
each ~~ DeletedEntry ifTrue:[aBlock value:each]. |
|
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
163 |
] |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
164 |
! ! |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
165 |
|
2182 | 166 |
!Registry methodsFor:'private'! |
167 |
||
20041 | 168 |
findKeyOrNil:key |
169 |
"Look for the key in the receiver. |
|
170 |
If it is found, return the index, |
|
171 |
otherwise the index of the first unused slot. |
|
172 |
Grow the receiver, if key was not found, and no unused slots were present. |
|
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
173 |
|
20041 | 174 |
Warning: an empty slot MUST be filled by the sender - it is only to be sent |
175 |
by at:put: / add: - like methods. |
|
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
176 |
|
20041 | 177 |
Redefined to not nil values of expired keys here." |
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
178 |
|
20041 | 179 |
|index "{ Class:SmallInteger }" |
180 |
length "{ Class:SmallInteger }" |
|
181 |
startIndex probe |
|
182 |
delIndex "{ Class:SmallInteger }"| |
|
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
183 |
|
20041 | 184 |
(OperatingSystem blockInterrupts) ifFalse:[ |
185 |
"/ |
|
186 |
"/ may never be entered with interrupts enabled |
|
187 |
"/ |
|
188 |
OperatingSystem unblockInterrupts. |
|
189 |
self error:'unblocked call of findKeyOrNil'. |
|
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
190 |
]. |
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
191 |
|
20041 | 192 |
delIndex := 0. |
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
193 |
|
20041 | 194 |
length := keyArray basicSize. |
195 |
startIndex := index := self initialIndexForKey:key. |
|
2449
788bba151e8a
validate - searching for a negative tally bug (olbi)
Claus Gittinger <cg@exept.de>
parents:
2414
diff
changeset
|
196 |
|
20041 | 197 |
[ |
198 |
probe := keyArray basicAt:index. |
|
199 |
key == probe ifTrue:[^ index]. |
|
200 |
probe isNil ifTrue:[ |
|
201 |
delIndex == 0 ifTrue:[^ index]. |
|
202 |
keyArray basicAt:delIndex put:nil. |
|
203 |
^ delIndex |
|
204 |
]. |
|
2182 | 205 |
|
20041 | 206 |
(delIndex == 0 and:[probe == DeletedEntry]) ifTrue:[ |
207 |
delIndex := index |
|
208 |
]. |
|
2414
215e58d26a05
added indexTable for fast finding of a registeredObjects slotIndex.
Claus Gittinger <cg@exept.de>
parents:
2278
diff
changeset
|
209 |
|
20041 | 210 |
index == length ifTrue:[ |
211 |
index := 1 |
|
212 |
] ifFalse:[ |
|
213 |
index := index + 1 |
|
214 |
]. |
|
215 |
index == startIndex ifTrue:[ |
|
216 |
delIndex ~~ 0 ifTrue:[ |
|
217 |
keyArray basicAt:delIndex put:nil. |
|
218 |
^ delIndex |
|
219 |
]. |
|
220 |
self grow. |
|
221 |
length := keyArray basicSize. |
|
222 |
startIndex := index := self initialIndexForKey:key. |
|
223 |
]. |
|
224 |
] loop. |
|
4435
6461ba759d1b
changes to allow effective subclassing by CachingRegistry
Claus Gittinger <cg@exept.de>
parents:
4257
diff
changeset
|
225 |
|
20041 | 226 |
"Modified: 30.1.1997 / 15:04:34 / cg" |
227 |
"Modified: 1.10.1997 / 11:25:32 / stefan" |
|
20235 | 228 |
! |
229 |
||
230 |
findKeyOrNilOrDeletedEntry:key |
|
231 |
"Look for the key in the receiver. |
|
232 |
If it is found, return the index, |
|
233 |
otherwise the index of the first unused slot. |
|
234 |
Grow the receiver, if key was not found, and no unused slots were present. |
|
235 |
||
236 |
Redefined to not nil values of expired keys here." |
|
237 |
||
238 |
|index "{ Class:SmallInteger }" |
|
239 |
length "{ Class:SmallInteger }" |
|
240 |
startIndex probe |
|
241 |
delIndex "{ Class:SmallInteger }"| |
|
242 |
||
243 |
(OperatingSystem blockInterrupts) ifFalse:[ |
|
244 |
"/ |
|
245 |
"/ may never be entered with interrupts enabled |
|
246 |
"/ |
|
247 |
OperatingSystem unblockInterrupts. |
|
248 |
self error:'unblocked call of findKeyOrNil'. |
|
249 |
]. |
|
250 |
||
251 |
delIndex := 0. |
|
252 |
||
253 |
length := keyArray basicSize. |
|
254 |
startIndex := index := self initialIndexForKey:key. |
|
255 |
||
256 |
[ |
|
257 |
probe := keyArray basicAt:index. |
|
258 |
key == probe ifTrue:[^ index]. |
|
259 |
probe isNil ifTrue:[ |
|
260 |
delIndex == 0 ifTrue:[^ index]. |
|
261 |
^ delIndex |
|
262 |
]. |
|
263 |
||
264 |
(delIndex == 0 and:[probe == DeletedEntry]) ifTrue:[ |
|
265 |
delIndex := index |
|
266 |
]. |
|
267 |
||
268 |
index == length ifTrue:[ |
|
269 |
index := 1 |
|
270 |
] ifFalse:[ |
|
271 |
index := index + 1 |
|
272 |
]. |
|
273 |
index == startIndex ifTrue:[ |
|
274 |
delIndex ~~ 0 ifTrue:[ |
|
275 |
^ delIndex |
|
276 |
]. |
|
277 |
self grow. |
|
278 |
length := keyArray basicSize. |
|
279 |
startIndex := index := self initialIndexForKey:key. |
|
280 |
]. |
|
281 |
] loop. |
|
282 |
||
283 |
"Modified: 30.1.1997 / 15:04:34 / cg" |
|
284 |
"Modified: 1.10.1997 / 11:25:32 / stefan" |
|
7810 | 285 |
! ! |
286 |
||
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
287 |
!Registry methodsFor:'registering objects'! |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
288 |
|
1 | 289 |
register:anObject |
290 |
"register anObject, so that a copy of it gets the disposed message |
|
2 | 291 |
when anObject dies (some time in the future)" |
1 | 292 |
|
6788 | 293 |
|executor| |
294 |
||
295 |
executor := anObject executor. |
|
296 |
executor notNil ifTrue:[ |
|
20041 | 297 |
self register:anObject as:executor. |
6788 | 298 |
]. |
375 | 299 |
! |
300 |
||
301 |
register:anObject as:aHandle |
|
302 |
"register anObject, so that I later receive informDispose: with aHandle |
|
303 |
(some time in the future)" |
|
304 |
||
20041 | 305 |
aHandle isNil ifTrue:[ |
306 |
self unregister:anObject. |
|
307 |
^ self. |
|
1484
3f4a4e5c5eb7
block interrupts while updating a registry
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
308 |
]. |
3f4a4e5c5eb7
block interrupts while updating a registry
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
309 |
|
20041 | 310 |
self at:anObject put:aHandle. |
1 | 311 |
! |
312 |
||
617 | 313 |
registerChange:anObject |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
314 |
"a registered object has changed, create a new executor" |
617 | 315 |
|
20041 | 316 |
self register:anObject as:anObject executor. |
617 | 317 |
! |
318 |
||
1 | 319 |
unregister:anObject |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
320 |
"remove registration of anObject, without telling the executor; |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
321 |
should be sent, if we are no more interested in destruction of |
1 | 322 |
anObject (i.e. it no longer holds external resources)." |
323 |
||
20041 | 324 |
self removeKey:anObject ifAbsent:[]. |
2091
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1961
diff
changeset
|
325 |
! |
c11bb3e29a1b
Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents:
1961
diff
changeset
|
326 |
|
2180
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
327 |
unregisterAllForWhich:aBlock |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
328 |
"remove registration of all entries, for which the argument block |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
329 |
evaluates to true. |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
330 |
should be sent, if we are no more interested in destruction of |
c3bfc8a9a114
added #unregisterAllForWhich:
Claus Gittinger <cg@exept.de>
parents:
2123
diff
changeset
|
331 |
a group of objects (i.e. it no longer holds external resources)." |
617 | 332 |
|
20041 | 333 |
|wasBlocked any| |
2414
215e58d26a05
added indexTable for fast finding of a registeredObjects slotIndex.
Claus Gittinger <cg@exept.de>
parents:
2278
diff
changeset
|
334 |
|
20041 | 335 |
wasBlocked := OperatingSystem blockInterrupts. |
336 |
keyArray validElementsDo:[:eachObject| |
|
337 |
(eachObject ~~ DeletedEntry and:[aBlock value:eachObject]) ifTrue:[ |
|
338 |
self safeRemoveKey:eachObject. |
|
339 |
any := true. |
|
18788 | 340 |
]. |
20041 | 341 |
]. |
342 |
any ifTrue:[ self possiblyShrink ]. |
|
343 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
9009
9da0a95a3994
addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents:
7810
diff
changeset
|
344 |
! |
9da0a95a3994
addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents:
7810
diff
changeset
|
345 |
|
9da0a95a3994
addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents:
7810
diff
changeset
|
346 |
unregisterAllForWhichHandle:aBlock |
20041 | 347 |
"remove registration of all handles, for which the argument block |
348 |
evaluates to true. |
|
349 |
should be sent, if we are no more interested in destruction of |
|
350 |
a group of objects (i.e. it no longer holds external resources)." |
|
9009
9da0a95a3994
addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents:
7810
diff
changeset
|
351 |
|
20041 | 352 |
|wasBlocked any| |
9009
9da0a95a3994
addons and fixes for X11-deviceHandle fix
Claus Gittinger <cg@exept.de>
parents:
7810
diff
changeset
|
353 |
|
20041 | 354 |
wasBlocked := OperatingSystem blockInterrupts. |
355 |
self keysAndValuesDo:[:eachObject :eachHandle| |
|
356 |
(eachObject class ~~ SmallInteger and:[aBlock value:eachHandle]) ifTrue:[ |
|
357 |
self safeRemoveKey:eachObject. |
|
358 |
any := true. |
|
18788 | 359 |
]. |
20041 | 360 |
]. |
361 |
any ifTrue:[ self possiblyShrink ]. |
|
362 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
617 | 363 |
! ! |
364 |
||
1961 | 365 |
!Registry class methodsFor:'documentation'! |
630 | 366 |
|
367 |
version |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
368 |
^ '$Header$' |
13012 | 369 |
! |
370 |
||
371 |
version_CVS |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
15350
diff
changeset
|
372 |
^ '$Header$' |
630 | 373 |
! ! |
15007 | 374 |