WeakIdentityDictionary.st
author Claus Gittinger <cg@exept.de>
Thu, 30 Jan 1997 15:07:11 +0100
changeset 2329 937fc97d5544
parent 2315 a9ff2fda8bae
child 2738 2546e06df154
permissions -rw-r--r--
must always nil empty slots in #findKeyOrNil: (to keep reimplementors of add: / at:put: in subclasses of set happy)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
     1
"
62211a9bc04d Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
358
claus
parents: 159
diff changeset
     3
	      All Rights Reserved
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
     4
62211a9bc04d Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
62211a9bc04d Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
62211a9bc04d Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
62211a9bc04d Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
62211a9bc04d Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
62211a9bc04d Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
62211a9bc04d Initial revision
claus
parents:
diff changeset
    11
"
62211a9bc04d Initial revision
claus
parents:
diff changeset
    12
62211a9bc04d Initial revision
claus
parents:
diff changeset
    13
IdentityDictionary subclass:#WeakIdentityDictionary
1054
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    14
	instanceVariableNames:''
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    15
	classVariableNames:''
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    16
	poolDictionaries:''
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    17
	category:'Collections-Unordered'
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
    18
!
62211a9bc04d Initial revision
claus
parents:
diff changeset
    19
10
claus
parents: 6
diff changeset
    20
!WeakIdentityDictionary class methodsFor:'documentation'!
claus
parents: 6
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    24
 COPYRIGHT (c) 1992 by Claus Gittinger
358
claus
parents: 159
diff changeset
    25
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    34
!
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    35
10
claus
parents: 6
diff changeset
    36
documentation
claus
parents: 6
diff changeset
    37
"
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    38
    WeakIdentityDictionaries behave like IdentityDictionaries, 
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
    39
    as long as the keys are still referenced by some 
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    40
    other (non-weak) object.
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    41
    However, once the last non-weak reference ceases to exist,
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    42
    the object will be automatically removed from the Weakcollection
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    43
    (with some delay: it will be removed after the next garbage collect).
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    44
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    45
    This class was added to support keeping track of dependents without
88
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    46
    keeping the values alive - values simply become nil when no one else
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    47
    references it. The original dependency mechanism used a regular Dictionary,
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    48
    which usually leads to a lot of garbage being kept due to a forgotten
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    49
    release. Using a WeakDictionary may be incompatible to ST-80 but is much
81dacba7a63a *** empty log message ***
claus
parents: 63
diff changeset
    50
    more comfortable, since no manual release of dependents is needed.
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    51
2306
3851fc553893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    52
    [Warning:]
3851fc553893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    53
      If you use this, be very careful since the collections size changes
3851fc553893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    54
      'magically' - for example, testing for being nonEmpty and then
3851fc553893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    55
      removing the first element may fail, since the element may vanish inbetween.
3851fc553893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2303
diff changeset
    56
      In general, never trust the value as returned by the size/isEmpty messages.
2260
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
    57
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
    58
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    59
    [author:]
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    60
        Claus Gittinger
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    61
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 1256
diff changeset
    62
    [See also:]
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
    63
        WeakArray WeakValueDictionary WeakIdentitySet
10
claus
parents: 6
diff changeset
    64
"
claus
parents: 6
diff changeset
    65
! !
claus
parents: 6
diff changeset
    66
359
claus
parents: 358
diff changeset
    67
!WeakIdentityDictionary methodsFor:'adding & removing'!
claus
parents: 358
diff changeset
    68
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    69
at:key
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    70
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    71
    |val|
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    72
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    73
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    74
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    75
        ^ super at:key.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    76
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    77
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    78
    [
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    79
        val := super at:key.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    80
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    81
        OperatingSystem unblockInterrupts.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    82
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    83
    ^ val
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    84
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    85
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    86
    "Modified: 29.1.1997 / 15:07:44 / cg"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    87
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    88
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    89
at:key ifAbsent:exceptionBlock
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    90
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    91
    |val|
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    92
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    93
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    94
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    95
        ^ super at:key ifAbsent:exceptionBlock.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    96
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    97
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    98
    [
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    99
        val := super at:key ifAbsent:exceptionBlock.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   100
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   101
        OperatingSystem unblockInterrupts.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   102
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   103
    ^ val
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   104
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   105
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   106
    "Modified: 29.1.1997 / 15:08:07 / cg"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   107
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   108
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   109
at:key put:anObject
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   110
    "add the argument anObject under key, aKey to the receiver.
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   111
     Return anObject (sigh).
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   112
     Redefined to block interrupts, to avoid trouble when dependencies
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   113
     are added within interrupting high prio processes."
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   114
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   115
    |val|
359
claus
parents: 358
diff changeset
   116
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   117
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   118
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   119
        ^ super at:key put:anObject.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   120
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   121
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   122
    [
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   123
        val := super at:key put:anObject.
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   124
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   125
        OperatingSystem unblockInterrupts.
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   126
    ].
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   127
    ^ val
1223
09d16bc18493 at:put: returns its arg
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   128
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   129
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   130
    "Modified: 29.1.1997 / 15:08:45 / cg"
359
claus
parents: 358
diff changeset
   131
!
claus
parents: 358
diff changeset
   132
claus
parents: 358
diff changeset
   133
removeKey:aKey ifAbsent:aBlock
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   134
    "remove the association under aKey from the collection,
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   135
     return the value previously stored there..
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   136
     If it was not in the collection return the result 
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   137
     from evaluating aBlock.
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   138
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   139
    Redefined to avoid synchronization problems, in case
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   140
    of interrupts (otherwise, there could be some other operation 
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   141
    on the receiver done by another process, which garbles my contents)."
1054
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
   142
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   143
    |ret|
359
claus
parents: 358
diff changeset
   144
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   145
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   146
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   147
        ^ super removeKey:aKey ifAbsent:aBlock.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   148
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   149
359
claus
parents: 358
diff changeset
   150
    [
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   151
        ret := super removeKey:aKey ifAbsent:aBlock
359
claus
parents: 358
diff changeset
   152
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   153
        OperatingSystem unblockInterrupts
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   154
    ].
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   155
    ^ ret
1054
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
   156
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   157
    "Modified: 6.5.1996 / 12:44:51 / stefan"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   158
    "Modified: 29.1.1997 / 15:09:11 / cg"
359
claus
parents: 358
diff changeset
   159
! !
claus
parents: 358
diff changeset
   160
10
claus
parents: 6
diff changeset
   161
!WeakIdentityDictionary methodsFor:'element disposal'!
claus
parents: 6
diff changeset
   162
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   163
update:something with:aParameter from:changedObject
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   164
    "an element (either key or value) died - clear out slots for
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   165
     disposed keys."
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
   166
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   167
    |wasBlocked|
358
claus
parents: 159
diff changeset
   168
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   169
    something == #ElementExpired ifTrue:[
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   170
        "
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   171
         have to block here - dispose may be done at a low priority
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   172
         from the background finalizer. If new items are added by a 
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   173
         higher prio process, the dictionary might get corrupted otherwise
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   174
        "
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   175
        wasBlocked := OperatingSystem blockInterrupts.
10
claus
parents: 6
diff changeset
   176
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   177
        keyArray 
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   178
            forAllDeadIndicesDo:[:idx | 
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   179
                                    valueArray basicAt:idx put:nil.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   180
                                    tally := tally - 1.
2027
4a2cdf9946ae replace items with DeletedEntry, when objects are collected.
ca
parents: 1790
diff changeset
   181
                                ]
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   182
            replacingCorpsesWith:DeletedEntry.
358
claus
parents: 159
diff changeset
   183
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   184
        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   185
    ]
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   186
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   187
    "Created: 7.1.1997 / 16:59:30 / stefan"
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
   188
! !
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   189
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   190
!WeakIdentityDictionary methodsFor:'private'!
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   191
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   192
findKeyOrNil:key
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   193
    "Look for the key in the receiver.  
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   194
     If it is found, return return the index,
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   195
     otherwise the index of the first unused slot. 
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   196
     Grow the receiver, if key was not found, and no unused slots were present.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   197
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   198
     Warning: an empty slot MUST be filled by the sender - it is only to be sent
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   199
              by at:put: / add: - like methods."
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   200
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   201
    |index  "{ Class:SmallInteger }"
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   202
     length "{ Class:SmallInteger }"
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   203
     startIndex probe 
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   204
     delIndex "{ Class:SmallInteger }"|
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   205
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   206
    (OperatingSystem blockInterrupts) ifFalse:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   207
        "/
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   208
        "/ may never be entered with interrupts enabled
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   209
        "/
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   210
        OperatingSystem unblockInterrupts.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   211
        self error:'oops - unblocked call of findKeyOrNil'.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   212
        ^ nil "/ leads to another error, if proceeded
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   213
    ].
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   214
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   215
    delIndex := 0.
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   216
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   217
    length := keyArray basicSize.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   218
    index := key identityHash.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   219
    index < 16r1FFFFFFF ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   220
        index := index * 2
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   221
    ].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   222
    index := index \\ length + 1.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   223
    startIndex := index.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   224
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   225
    [true] whileTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   226
        probe := keyArray basicAt:index.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   227
        key == probe ifTrue:[^ index].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   228
        probe isNil ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   229
            delIndex == 0 ifTrue:[^ index].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   230
            keyArray basicAt:delIndex put:nil.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   231
            ^ delIndex
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   232
        ].
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   233
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   234
        probe == 0 ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   235
            probe := DeletedEntry.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   236
            keyArray basicAt:index put:probe.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   237
            valueArray basicAt:index put:nil.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   238
            tally := tally - 1.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   239
        ].
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   240
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   241
        delIndex == 0 ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   242
            probe == DeletedEntry ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   243
                delIndex := index
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   244
            ]
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   245
        ].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   246
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   247
        index == length ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   248
            index := 1
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   249
        ] ifFalse:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   250
            index := index + 1
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   251
        ].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   252
        index == startIndex ifTrue:[
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   253
            delIndex ~~ 0 ifTrue:[
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   254
                keyArray basicAt:delIndex put:nil.
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   255
                ^ delIndex
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   256
            ].
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   257
            ^ self grow findKeyOrNil:key
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   258
        ].
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   259
    ]
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   260
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   261
    "Modified: 30.1.1997 / 15:04:34 / cg"
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   262
!
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   263
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   264
grow:newSize
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   265
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   266
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   267
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   268
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   269
"/ 'grow:' printCR.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   270
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   271
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   272
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   273
        ^ super grow:newSize.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   274
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   275
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   276
    [
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   277
        super grow:newSize
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   278
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   279
        OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   280
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   281
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   282
    "Created: 28.1.1997 / 23:41:39 / cg"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   283
    "Modified: 29.1.1997 / 15:10:12 / cg"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   284
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   285
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   286
keyContainerOfSize:n
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   287
    "return a container for keys of size n.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   288
     use WeakArrays here, but dont make me a depenent of it."
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   289
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   290
    |w|
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   291
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   292
    w := WeakArray new:n.
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   293
    w addDependent:self.
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   294
    ^ w
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   295
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   296
    "Modified: 7.1.1997 / 17:01:15 / stefan"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   297
    "Modified: 29.1.1997 / 14:18:49 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   298
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   299
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   300
rehash
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   301
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   302
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   303
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   304
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   305
"/ 'rehash' printCR.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   306
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   307
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   308
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   309
        ^ super rehash.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   310
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   311
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   312
    [
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   313
        super rehash
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   314
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   315
        OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   316
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   317
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   318
    "Created: 29.1.1997 / 11:39:42 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   319
    "Modified: 29.1.1997 / 14:18:52 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   320
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   321
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   322
setTally:count
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   323
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   324
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   325
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   326
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   327
"/ 'setTally:' printCR.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   328
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   329
    (OperatingSystem blockInterrupts) ifTrue:[
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   330
        "/ already blocked
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   331
        ^ super setTally:count.
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   332
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   333
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   334
    [
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   335
        super setTally:count
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   336
    ] valueNowOrOnUnwindDo:[
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   337
        OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   338
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   339
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   340
    "Created: 29.1.1997 / 11:40:12 / cg"
2303
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   341
    "Modified: 29.1.1997 / 15:11:11 / cg"
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   342
! !
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   343
635
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   344
!WeakIdentityDictionary class methodsFor:'documentation'!
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   345
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   346
version
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   347
    ^ '$Header: /cvs/stx/stx/libbasic/WeakIdentityDictionary.st,v 1.29 1997-01-30 14:07:11 cg Exp $'
635
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   348
! !