--- a/WeakValueDictionary.st Thu Jul 23 12:40:48 2015 +0200
+++ b/WeakValueDictionary.st Thu Jul 23 13:10:17 2015 +0200
@@ -38,8 +38,8 @@
documentation
"
- WeakValueDictionaries behave like Dictionaries,
- as long as the values are still referenced by some
+ WeakValueDictionaries behave like Dictionaries,
+ as long as the values are still referenced by some
other (non-weak) object.
However, once the last non-weak reference ceases to exist,
the Dictionary will return nil for the value at position key.
@@ -52,10 +52,10 @@
In general, never trust the value as returned by the size/isEmpty messages.
[author:]
- Stefan Vogel
+ Stefan Vogel
[See also:]
- WeakArray WeakIdentityDictionary WeakIdentitySet
+ WeakArray WeakIdentityDictionary WeakIdentitySet
"
! !
@@ -70,10 +70,10 @@
|ret|
[
- ret := super at:key ifAbsent:[^ somethingRespondingToValue value].
- ret = 0 ifTrue:[
- ret := somethingRespondingToValue value
- ].
+ ret := super at:key ifAbsent:[^ somethingRespondingToValue value].
+ ret class == SmallInteger ifTrue:[
+ ret := somethingRespondingToValue value
+ ].
] valueUninterruptably.
^ ret
!
@@ -86,12 +86,12 @@
Redefined to block interrupts, to avoid trouble when dependencies
are added within interrupting high prio processes.
WARNING: do not add elements while iterating over the receiver.
- Iterate over a copy to do this."
+ Iterate over a copy to do this."
|ret|
[
- ret := super at:key ifAbsentPut:anObject.
+ ret := super at:key ifAbsentPut:anObject.
] valueUninterruptably.
^ ret
!
@@ -105,7 +105,7 @@
|ret|
[
- ret := super at:key put:anObject.
+ ret := super at:key put:anObject.
] valueUninterruptably.
^ ret
@@ -117,17 +117,17 @@
removeKey:aKey ifAbsent:aBlock
"remove the association under aKey from the collection,
return the value previously stored there.
- If it was not in the collection return the result
+ If it was not in the collection return the result
from evaluating aBlock.
Redefined to avoid synchronization problems, in case
- of interrupts (otherwise, there could be some other operation
+ of interrupts (otherwise, there could be some other operation
on the receiver done by another process, which garbles my contents)."
|ret|
[
- ret := super removeKey:aKey ifAbsent:aBlock
+ ret := super removeKey:aKey ifAbsent:aBlock
] valueUninterruptably.
^ ret
@@ -138,17 +138,17 @@
removeValue:aKey ifAbsent:aBlock
"remove the association under aValue from the collection,
return the key previously stored there.
- If it was not in the collection return the result
+ If it was not in the collection return the result
from evaluating aBlock.
Redefined to avoid synchronization problems, in case
- of interrupts (otherwise, there could be some other operation
+ of interrupts (otherwise, there could be some other operation
on the receiver done by another process, which garbles my contents)."
|ret|
[
- ret := super removeValue:aKey ifAbsent:aBlock
+ ret := super removeValue:aKey ifAbsent:aBlock
] valueUninterruptably.
^ ret.
@@ -165,7 +165,7 @@
|wasBlocked|
something == #ElementExpired ifTrue:[
- self clearDeadSlots.
+ self clearDeadSlots.
]
"Created: 7.1.1997 / 16:59:30 / stefan"
@@ -178,19 +178,19 @@
"
have to block here - dispose may be done at a low priority
- from the background finalizer. If new items are added by a
+ from the background finalizer. If new items are added by a
higher prio process, the dictionary might get corrupted otherwise
"
wasBlocked := OperatingSystem blockInterrupts.
- valueArray
- forAllDeadIndicesDo:[:idx | keyArray at:idx put:DeletedEntry.
- tally := tally - 1.
- ]
- replacingCorpsesWith:nil.
+ valueArray
+ forAllDeadIndicesDo:[:idx | keyArray at:idx put:DeletedEntry.
+ tally := tally - 1.
+ ]
+ replacingCorpsesWith:nil.
wasBlocked ifFalse:[
- OperatingSystem unblockInterrupts.
+ OperatingSystem unblockInterrupts.
].
"Modified: / 13.12.2001 / 14:18:56 / martin"
@@ -225,13 +225,13 @@
!WeakValueDictionary methodsFor:'testing'!
includes:anObject
- "redefined to block interrupts
+ "redefined to block interrupts
(avoid change of the dictionary while accessing)"
|val|
[
- val := super includes:anObject.
+ val := super includes:anObject.
] valueUninterruptably.
^ val
@@ -241,13 +241,13 @@
!
includesKey:key
- "redefined to block interrupts
+ "redefined to block interrupts
(avoid change of the dictionary while accessing)"
|val|
[
- val := super includesKey:key.
+ val := super includesKey:key.
] valueUninterruptably.
^ val
@@ -265,6 +265,6 @@
!WeakValueDictionary class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/WeakValueDictionary.st,v 1.20 2014-12-30 12:35:34 cg Exp $'
+ ^ '$Header$'
! !