8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libview2' }" |
12 "{ Package: 'stx:libview2' }" |
|
13 |
|
14 "{ NameSpace: Smalltalk }" |
13 |
15 |
14 ValueHolder subclass:#ValueHolderWithWeakDependents |
16 ValueHolder subclass:#ValueHolderWithWeakDependents |
15 instanceVariableNames:'' |
17 instanceVariableNames:'' |
16 classVariableNames:'' |
18 classVariableNames:'' |
17 poolDictionaries:'' |
19 poolDictionaries:'' |
101 "/ Used to use #valueUninterruptably here; inlined that code for slightly |
103 "/ Used to use #valueUninterruptably here; inlined that code for slightly |
102 "/ faster execution. |
104 "/ faster execution. |
103 |
105 |
104 wasBlocked := OperatingSystem blockInterrupts. |
106 wasBlocked := OperatingSystem blockInterrupts. |
105 [ |
107 [ |
106 |deps n d| |
108 |deps n dep| |
107 |
109 |
108 deps := dependents. |
110 deps := dependents. |
109 deps size ~~ 0 ifTrue:[ |
111 deps size ~~ 0 ifTrue:[ |
|
112 "/ to save a fair amount of memory in case of |
|
113 "/ many dependencies, we store a single dependent in |
|
114 "/ a WeakArray, and switch to a WeakSet if more dependents are |
|
115 "/ added. Here we have to do the inverse ... |
110 |
116 |
111 "/ to save a fair amount of memory in case of |
117 deps class == WeakArray ifTrue:[ |
112 "/ many dependencies, we store a single dependent in |
118 ((dep := deps at:1) == anObject |
113 "/ a WeakArray, and switch to a WeakSet if more dependents are |
119 or:[dep isNil |
114 "/ added. Here we have to do the inverse ... |
120 or:[dep class == SmallInteger]]) ifTrue:[ |
115 |
121 dependents := nil |
116 deps class == WeakArray ifTrue:[ |
122 ] |
117 ((d := deps at:1) == anObject |
123 ] ifFalse:[ |
118 or:[d isNil |
124 dep := deps remove:anObject ifAbsent:[]. |
119 or:[d class == SmallInteger]]) ifTrue:[ |
125 "if dep is nil, nothing has changed" |
120 dependents := nil |
126 dep notNil ifTrue:[ |
121 ] |
127 (n := deps size) == 0 ifTrue:[ |
122 ] ifFalse:[ |
128 dependents := nil |
123 deps remove:anObject ifAbsent:[]. |
129 ] ifFalse:[ |
124 (n := deps size) == 0 ifTrue:[ |
130 n == 1 ifTrue:[ |
125 dependents := nil |
131 dep := deps firstIfEmpty:nil. |
126 ] ifFalse:[ |
132 dep notNil ifTrue:[ |
127 n == 1 ifTrue:[ |
133 deps := WeakArray with:dep |
128 d := deps firstIfEmpty:nil. |
134 ] ifFalse:[ |
129 d notNil ifTrue:[ |
135 deps := nil |
130 deps := WeakArray with:d |
136 ]. |
131 ] ifFalse:[ |
137 dependents := deps. |
132 deps := nil |
138 ] |
133 ]. |
139 ] |
134 dependents := deps. |
140 ]. |
135 ] |
141 ] |
136 ] |
142 ] |
137 ] |
|
138 ] |
|
139 ] ensure:[ |
143 ] ensure:[ |
140 wasBlocked ifFalse:[ |
144 wasBlocked ifFalse:[ |
141 OperatingSystem unblockInterrupts |
145 OperatingSystem unblockInterrupts |
142 ] |
146 ] |
143 ] |
147 ] |
144 |
148 |
145 "Modified: / 26.1.1998 / 19:51:50 / cg" |
149 "Modified: / 26.1.1998 / 19:51:50 / cg" |
146 ! ! |
150 ! ! |
147 |
151 |
148 !ValueHolderWithWeakDependents class methodsFor:'documentation'! |
152 !ValueHolderWithWeakDependents class methodsFor:'documentation'! |
149 |
153 |
150 version |
154 version |
151 ^ '$Header$' |
155 ^ '$Header$' |
152 ! ! |
156 ! ! |
|
157 |