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