WeakIdentityDictionary.st
changeset 20702 5dfa0631a814
parent 20237 855a12ebe6f9
child 20990 38e8d0c58aa1
child 21024 8734987eb5c7
equal deleted inserted replaced
20701:32a0109f2ccb 20702:5dfa0631a814
   211 ! !
   211 ! !
   212 
   212 
   213 !WeakIdentityDictionary methodsFor:'element disposal'!
   213 !WeakIdentityDictionary methodsFor:'element disposal'!
   214 
   214 
   215 clearDeadSlots
   215 clearDeadSlots
   216     |wasBlocked|
   216     |wasBlocked anyChange|
   217 
   217 
   218     "
   218     "
   219      have to block here - dispose may be done at a low priority
   219      have to block here - dispose may be done at a low priority
   220      from the background finalizer. If new items are added by a
   220      from the background finalizer. If new items are added by a
   221      higher prio process, the dictionary might get corrupted otherwise
   221      higher prio process, the dictionary might get corrupted otherwise
   222     "
   222     "
   223     wasBlocked := OperatingSystem blockInterrupts.
   223     wasBlocked := OperatingSystem blockInterrupts.
   224     [
   224     anyChange := false.
   225 	keyArray
   225     [
   226 	    forAllDeadIndicesDo:[:idx |
   226         keyArray
   227 				    valueArray basicAt:idx put:nil.
   227             forAllDeadIndicesDo:[:idx |
   228 				    tally := tally - 1.
   228                                     valueArray basicAt:idx put:nil.
   229 				]
   229                                     tally := tally - 1.
   230 	    replacingCorpsesWith:DeletedEntry.
   230                                     anyChange := true.
   231     ] ensure:[
   231                                 ]
   232 	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
   232             replacingCorpsesWith:DeletedEntry.
   233     ].
   233     ] ensure:[
       
   234         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
   235     ].
       
   236     anyChange ifTrue:[
       
   237         self changed:#ElementExpired
       
   238     ].    
   234 
   239 
   235     "Modified: / 13.12.2001 / 14:18:17 / martin"
   240     "Modified: / 13.12.2001 / 14:18:17 / martin"
   236 !
   241 !
   237 
   242 
   238 update:something with:aParameter from:changedObject
   243 update:something with:aParameter from:changedObject