WeakIdDict.st
changeset 2091 c11bb3e29a1b
parent 2027 4a2cdf9946ae
child 2260 96d898c2874d
equal deleted inserted replaced
2090:42653edf4cc5 2091:c11bb3e29a1b
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
       
    12 
       
    13 'From Smalltalk/X, Version:3.1.3 on 7-jan-1997 at 17:23:20'                     !
    12 
    14 
    13 IdentityDictionary subclass:#WeakIdentityDictionary
    15 IdentityDictionary subclass:#WeakIdentityDictionary
    14 	instanceVariableNames:''
    16 	instanceVariableNames:''
    15 	classVariableNames:''
    17 	classVariableNames:''
    16 	poolDictionaries:''
    18 	poolDictionaries:''
   103     "Modified: 6.5.1996 / 12:44:51 / stefan"
   105     "Modified: 6.5.1996 / 12:44:51 / stefan"
   104 ! !
   106 ! !
   105 
   107 
   106 !WeakIdentityDictionary methodsFor:'element disposal'!
   108 !WeakIdentityDictionary methodsFor:'element disposal'!
   107 
   109 
   108 informDispose
   110 update:something with:aParameter from:changedObject
   109     "an element (either key or value) died - rehash"
   111     "an element (either key or value) died - rehash"
   110 
   112 
   111     | wasBlocked |
   113     |wasBlocked|
   112 
   114 
   113     "
   115     something == #ElementExpired ifTrue:[
   114      have to block here - dispose may be done at a low priority
   116         "
   115      from the background finalizer. If new views are opened in
   117          have to block here - dispose may be done at a low priority
   116      the foreground, the dependency dictionary may get corrupted
   118          from the background finalizer. If new views are opened in
   117      otherwise
   119          the foreground, the dependency dictionary may get corrupted
   118     "
   120          otherwise
   119     wasBlocked := OperatingSystem blockInterrupts.
   121         "
       
   122         wasBlocked := OperatingSystem blockInterrupts.
   120 
   123 
   121     keyArray 
   124         keyArray 
   122         forAllDeadIndicesDo:[:idx | 
   125             forAllDeadIndicesDo:[:idx | 
   123                                 (valueArray at:idx) notNil ifTrue:[
   126                                     (valueArray at:idx) notNil ifTrue:[
   124                                     keyArray basicAt:idx put:DeletedEntry.
   127                                         keyArray basicAt:idx put:DeletedEntry.
   125                                     valueArray basicAt:idx put:nil.
   128                                         valueArray basicAt:idx put:nil.
   126                                     tally := tally - 1.
   129                                         tally := tally - 1.
       
   130                                     ]
   127                                 ]
   131                                 ]
   128                             ]
   132             replacingCorpsesWith:DeletedEntry.
   129         replacingCorpsesWith:DeletedEntry.
       
   130 
   133 
   131     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
   134         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
   135     ]
       
   136 
       
   137     "Created: 7.1.1997 / 16:59:30 / stefan"
   132 ! !
   138 ! !
   133 
   139 
   134 !WeakIdentityDictionary methodsFor:'private'!
   140 !WeakIdentityDictionary methodsFor:'private'!
   135 
   141 
   136 keyContainerOfSize:n
   142 keyContainerOfSize:n
   138      use WeakArrays here."
   144      use WeakArrays here."
   139 
   145 
   140     |w|
   146     |w|
   141 
   147 
   142     w := WeakArray new:n.
   148     w := WeakArray new:n.
   143     w watcher:self.
   149     w addDependent:self.
   144     ^ w
   150     ^ w
       
   151 
       
   152     "Modified: 7.1.1997 / 17:01:15 / stefan"
   145 ! !
   153 ! !
   146 
   154 
   147 !WeakIdentityDictionary class methodsFor:'documentation'!
   155 !WeakIdentityDictionary class methodsFor:'documentation'!
   148 
   156 
   149 version
   157 version
   150     ^ '$Header: /cvs/stx/stx/libbasic/Attic/WeakIdDict.st,v 1.22 1997-01-02 18:10:12 ca Exp $'
   158     ^ '$Header: /cvs/stx/stx/libbasic/Attic/WeakIdDict.st,v 1.23 1997-01-08 19:42:15 stefan Exp $'
   151 ! !
   159 ! !