WeakIdentityDictionary.st
author Claus Gittinger <cg@exept.de>
Wed, 07 Jul 1999 20:41:37 +0200
changeset 4350 5aa2a3b9fd5b
parent 2988 c6550b3e9b3c
child 4530 793b116fef3e
permissions -rw-r--r--
category change
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:''
4350
5aa2a3b9fd5b category change
Claus Gittinger <cg@exept.de>
parents: 2988
diff changeset
    17
	category:'Collections-Weak'
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:]
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    60
	Claus Gittinger
1290
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:]
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
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
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
    70
    "redefined to block interrupts 
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
    71
     (avoid change of the dictionary while accessing)"
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
    |val|
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    74
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
    75
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    76
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    77
	^ super at:key.
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
    78
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
    79
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    80
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    81
	val := super at:key.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    82
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    83
	OperatingSystem unblockInterrupts.
2298
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
    ^ val
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    86
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    87
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
    88
    "Modified: 1.7.1997 / 10:45:42 / cg"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    89
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    90
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    91
at:key ifAbsent:exceptionBlock
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
    92
    "redefined to block interrupts 
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
    93
     (avoid change of the dictionary while accessing)"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    94
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
    95
    |val|
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
    96
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
    97
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    98
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
    99
	^ super at:key ifAbsent:exceptionBlock.
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
   100
    ].
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
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   102
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   103
	val := super at:key ifAbsent:exceptionBlock.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   104
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   105
	OperatingSystem unblockInterrupts.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   106
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   107
    ^ val
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   108
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   109
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   110
    "Modified: 1.7.1997 / 10:45:47 / cg"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   111
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   112
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   113
at:key put:anObject
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   114
    "add the argument anObject under key, aKey to the receiver.
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   115
     Return anObject (sigh).
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   116
     Redefined to block interrupts, to avoid trouble when dependencies
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   117
     are added within interrupting high prio processes."
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   118
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
   119
    |val|
359
claus
parents: 358
diff changeset
   120
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
   121
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   122
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   123
	^ super at:key put:anObject.
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
   124
    ].
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
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   126
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   127
	val := super at:key put:anObject.
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   128
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   129
	OperatingSystem unblockInterrupts.
1790
4187e9fc7357 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1780
diff changeset
   130
    ].
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
   131
    ^ val
1223
09d16bc18493 at:put: returns its arg
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
   132
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   133
    "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
   134
    "Modified: 29.1.1997 / 15:08:45 / cg"
359
claus
parents: 358
diff changeset
   135
!
claus
parents: 358
diff changeset
   136
claus
parents: 358
diff changeset
   137
removeKey:aKey ifAbsent:aBlock
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   138
    "remove the association under aKey from the collection,
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   139
     return the value previously stored there.
1256
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   140
     If it was not in the collection return the result 
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   141
     from evaluating aBlock.
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   142
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   143
    Redefined to avoid synchronization problems, in case
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   144
    of interrupts (otherwise, there could be some other operation 
249fd57abee5 commentary
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   145
    on the receiver done by another process, which garbles my contents)."
1054
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
   146
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
   147
    |ret|
359
claus
parents: 358
diff changeset
   148
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
   149
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   150
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   151
	^ super removeKey:aKey ifAbsent:aBlock.
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
   152
    ].
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
359
claus
parents: 358
diff changeset
   154
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   155
	ret := super removeKey:aKey ifAbsent:aBlock
359
claus
parents: 358
diff changeset
   156
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   157
	OperatingSystem unblockInterrupts
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   158
    ].
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   159
    ^ ret
1054
62ce964f1d2e commentary
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
   160
1343
b0ee705c63e0 Correct return value when removing elements.
Stefan Vogel <sv@exept.de>
parents: 1290
diff changeset
   161
    "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
   162
    "Modified: 29.1.1997 / 15:09:11 / cg"
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   163
!
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   164
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   165
saveRemoveKey:key
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   166
    "redefined to block interrupts 
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   167
     (avoid change of the dictionary while accessing)"
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   168
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   169
    |val|
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   170
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   171
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   172
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   173
	^ super saveRemoveKey:key.
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   174
    ].
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   175
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   176
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   177
	val := super saveRemoveKey:key.
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   178
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   179
	OperatingSystem unblockInterrupts.
2738
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   180
    ].
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   181
    ^ val
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   182
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   183
    "Modified: 6.5.1996 / 12:22:26 / stefan"
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   184
    "Modified: 1.7.1997 / 10:45:52 / cg"
2546e06df154 more interrupt blocking (paranoia)
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
   185
    "Created: 1.7.1997 / 10:46:34 / cg"
359
claus
parents: 358
diff changeset
   186
! !
claus
parents: 358
diff changeset
   187
10
claus
parents: 6
diff changeset
   188
!WeakIdentityDictionary methodsFor:'element disposal'!
claus
parents: 6
diff changeset
   189
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   190
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
   191
    "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
   192
     disposed keys."
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
   193
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   194
    |wasBlocked|
358
claus
parents: 159
diff changeset
   195
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   196
    something == #ElementExpired ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   197
	"
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   198
	 have to block here - dispose may be done at a low priority
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   199
	 from the background finalizer. If new items are added by a 
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   200
	 higher prio process, the dictionary might get corrupted otherwise
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   201
	"
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   202
	wasBlocked := OperatingSystem blockInterrupts.
10
claus
parents: 6
diff changeset
   203
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   204
	keyArray 
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   205
	    forAllDeadIndicesDo:[:idx | 
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   206
				    valueArray basicAt:idx put:nil.
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   207
				    tally := tally - 1.
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   208
				]
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   209
	    replacingCorpsesWith:DeletedEntry.
358
claus
parents: 159
diff changeset
   210
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   211
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   212
    ]
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   213
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   214
    "Created: 7.1.1997 / 16:59:30 / stefan"
6
62211a9bc04d Initial revision
claus
parents:
diff changeset
   215
! !
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   216
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   217
!WeakIdentityDictionary methodsFor:'private'!
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   218
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   219
findKeyOrNil:key
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   220
    "Look for the key in the receiver.  
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   221
     If it is found, return the index,
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   222
     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
   223
     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
   224
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   225
     Warning: an empty slot MUST be filled by the sender - it is only to be sent
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   226
              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
   227
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   228
    |index  "{ Class:SmallInteger }"
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   229
     length "{ Class:SmallInteger }"
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   230
     startIndex probe 
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   231
     delIndex "{ Class:SmallInteger }"|
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
    (OperatingSystem blockInterrupts) ifFalse:[
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   234
        "/
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   235
        "/ may never be entered with interrupts enabled
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   236
        "/
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   237
        OperatingSystem unblockInterrupts.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   238
        self error:'oops - unblocked call of findKeyOrNil'.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   239
        ^ 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
   240
    ].
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   241
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   242
    delIndex := 0.
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   243
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   244
    length := keyArray basicSize.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   245
    index := key identityHash.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   246
    index < 16r1FFFFFFF ifTrue:[
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   247
        index := index * 2
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   248
    ].
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   249
    index := index \\ length + 1.
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   250
    startIndex := index.
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
    [true] whileTrue:[
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   253
        probe := keyArray basicAt:index.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   254
        key == probe ifTrue:[^ index].
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   255
        probe isNil ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   256
            delIndex == 0 ifTrue:[^ index].
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   257
            keyArray basicAt:delIndex put:nil.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   258
            ^ delIndex
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   259
        ].
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   260
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   261
        probe == 0 ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   262
            probe := DeletedEntry.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   263
            keyArray basicAt:index put:probe.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   264
            valueArray basicAt:index put:nil.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   265
            tally := tally - 1.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   266
        ].
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   267
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   268
        delIndex == 0 ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   269
            probe == DeletedEntry ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   270
                delIndex := index
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   271
            ]
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   272
        ].
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   273
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   274
        index == length ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   275
            index := 1
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   276
        ] ifFalse:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   277
            index := index + 1
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   278
        ].
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   279
        index == startIndex ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   280
            delIndex ~~ 0 ifTrue:[
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   281
                keyArray basicAt:delIndex put:nil.
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   282
                ^ delIndex
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   283
            ].
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   284
            ^ self grow findKeyOrNil:key
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   285
        ].
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   286
    ]
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   287
2329
937fc97d5544 must always nil empty slots in #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 2315
diff changeset
   288
    "Modified: 30.1.1997 / 15:04:34 / cg"
2988
c6550b3e9b3c Fix spelling.
Stefan Vogel <sv@exept.de>
parents: 2910
diff changeset
   289
    "Modified: 1.10.1997 / 11:25:32 / stefan"
2315
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   290
!
a9ff2fda8bae mhmh - be very careful when searching for some item.
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
   291
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   292
grow:newSize
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   293
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   294
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   295
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   296
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
   297
"/ 'grow:' printCR.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   298
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
   299
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   300
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   301
	^ super grow:newSize.
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
   302
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   303
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   304
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   305
	super grow:newSize
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   306
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   307
	OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   308
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   309
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   310
    "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
   311
    "Modified: 29.1.1997 / 15:10:12 / cg"
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
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   314
keyContainerOfSize:n
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   315
    "return a container for keys of size n.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   316
     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
   317
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   318
    |w|
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   319
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   320
    w := WeakArray new:n.
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   321
    w addDependent:self.
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   322
    ^ w
2091
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   323
c11bb3e29a1b Use dependent mechamism of WeakArray instead of #watcher.
Stefan Vogel <sv@exept.de>
parents: 2027
diff changeset
   324
    "Modified: 7.1.1997 / 17:01:15 / stefan"
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   325
    "Modified: 29.1.1997 / 14:18:49 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   326
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   327
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   328
rehash
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   329
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   330
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   331
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   332
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   333
"/ 'rehash' printCR.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   334
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
   335
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   336
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   337
	^ super rehash.
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
   338
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   339
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   340
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   341
	super rehash
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   342
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   343
	OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   344
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   345
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   346
    "Created: 29.1.1997 / 11:39:42 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   347
    "Modified: 29.1.1997 / 14:18:52 / cg"
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   348
!
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   349
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   350
setTally:count
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   351
    "grow the receiver.
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   352
     Redefined to block interrupts, to avoid trouble when dependencies
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   353
     are added within interrupting high prio processes."
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   354
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
   355
"/ 'setTally:' printCR.
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   356
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
   357
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   358
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   359
	^ super setTally:count.
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
   360
    ].
f19df2d4c238 avoid creation of a blocks if possible - if not, cheap ones are now created
Claus Gittinger <cg@exept.de>
parents: 2298
diff changeset
   361
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   362
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   363
	super setTally:count
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   364
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   365
	OperatingSystem unblockInterrupts
2298
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   366
    ].
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   367
e75dabb791dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   368
    "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
   369
    "Modified: 29.1.1997 / 15:11:11 / cg"
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   370
! !
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   371
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   372
!WeakIdentityDictionary methodsFor:'testing'!
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   373
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   374
includes:anObject
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   375
    "redefined to block interrupts 
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   376
     (avoid change of the dictionary while accessing)"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   377
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   378
    |val|
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   379
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   380
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   381
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   382
	^ super includes:anObject.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   383
    ].
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   384
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   385
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   386
	val := super includes:anObject.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   387
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   388
	OperatingSystem unblockInterrupts.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   389
    ].
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   390
    ^ val
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   391
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   392
    "Modified: 6.5.1996 / 12:22:26 / stefan"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   393
    "Modified: 1.7.1997 / 10:45:52 / cg"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   394
    "Created: 1.7.1997 / 10:47:13 / cg"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   395
!
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   396
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   397
includesKey:key
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   398
    "redefined to block interrupts 
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   399
     (avoid change of the dictionary while accessing)"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   400
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   401
    |val|
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   402
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   403
    (OperatingSystem blockInterrupts) ifTrue:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   404
	"/ already blocked
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   405
	^ super includesKey:key.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   406
    ].
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   407
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   408
    [
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   409
	val := super includesKey:key.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   410
    ] valueNowOrOnUnwindDo:[
2910
1a3e44b10f9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2741
diff changeset
   411
	OperatingSystem unblockInterrupts.
2741
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   412
    ].
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   413
    ^ val
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   414
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   415
    "Modified: 6.5.1996 / 12:22:26 / stefan"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   416
    "Created: 1.7.1997 / 10:45:14 / cg"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   417
    "Modified: 1.7.1997 / 10:45:52 / cg"
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   418
! !
7af858fd7296 category changes
Claus Gittinger <cg@exept.de>
parents: 2738
diff changeset
   419
635
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   420
!WeakIdentityDictionary class methodsFor:'documentation'!
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   421
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   422
version
4350
5aa2a3b9fd5b category change
Claus Gittinger <cg@exept.de>
parents: 2988
diff changeset
   423
    ^ '$Header: /cvs/stx/stx/libbasic/WeakIdentityDictionary.st,v 1.34 1999-07-07 18:41:04 cg Exp $'
635
86cbe76f5a20 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   424
! !