81 |
|
* via a background thread common across all maps. Because of the |
82 |
|
* potential for asynchronous clearing of References, methods such as |
83 |
|
* <code>containsValue</code> have weaker guarantees than you might |
84 |
< |
* expect even in the absence of other explicity concurrent |
84 |
> |
* expect even in the absence of other explicitly concurrent |
85 |
|
* operations. For example <code>containsValue(value)</code> may |
86 |
|
* return true even if <code>value</code> is no longer available upon |
87 |
|
* return from the method. |
275 |
|
*/ |
276 |
|
static interface NodeFactory extends Serializable { |
277 |
|
/** |
278 |
< |
* Creates and returns a Node using the given parameters |
278 |
> |
* Creates and returns a Node using the given parameters. |
279 |
> |
* |
280 |
|
* @param locator an opaque immutable locator for this node |
281 |
< |
* @parem key the (nonnull) immutable key |
282 |
< |
* @parem value the (nonnull) volatile value; |
283 |
< |
* @param cchm the table creating this node. |
281 |
> |
* @param key the (non-null) immutable key |
282 |
> |
* @param value the (non-null) volatile value |
283 |
> |
* @param cchm the table creating this node |
284 |
|
* @param linkage an opaque volatile linkage for maintaining this node |
285 |
|
*/ |
286 |
|
Node newNode(int locator, Object key, Object value, |
304 |
|
static interface Node extends Reclaimable { |
305 |
|
/** |
306 |
|
* Returns the key established during the creation of this node. |
307 |
< |
* Note: This method is named "get" rether than "getKey" |
307 |
> |
* Note: This method is named "get" rather than "getKey" |
308 |
|
* to simplify usage of Reference keys. |
309 |
|
* @return the key |
310 |
|
*/ |
333 |
|
void setValue(Object value); |
334 |
|
|
335 |
|
/** |
336 |
< |
* Returns the lonkage established during the creation of this |
336 |
> |
* Returns the linkage established during the creation of this |
337 |
|
* node or, if since updated, the linkage set by the most |
338 |
|
* recent call to setLinkage. |
339 |
|
* @return the linkage |
630 |
|
|
631 |
|
/** |
632 |
|
* Returns the segment for possibly inserting into the table |
633 |
< |
* associated with given hash, constructing it if necesary. |
633 |
> |
* associated with given hash, constructing it if necessary. |
634 |
|
* @param hash the hash code for the key |
635 |
|
* @return the segment |
636 |
|
*/ |
697 |
|
* if no such mapping exists |
698 |
|
* |
699 |
|
* @param key possible key |
700 |
< |
* @return the value associated with the kew or <tt>null</tt> if |
700 |
> |
* @return the value associated with the key or <tt>null</tt> if |
701 |
|
* there is no mapping. |
702 |
|
* @throws NullPointerException if the specified key is null |
703 |
|
*/ |
713 |
|
} |
714 |
|
|
715 |
|
/** |
716 |
< |
* Share dimplementation for put, putIfAbsent |
716 |
> |
* Shared implementation for put, putIfAbsent |
717 |
|
*/ |
718 |
|
final V doPut(K key, V value, boolean onlyIfNull) { |
719 |
|
if (key == null || value == null) |
956 |
|
while (p != null) { |
957 |
|
Node n = p.getLinkage(); |
958 |
|
if (p.get() != null && p.getValue() != null) { |
959 |
+ |
pred = p; |
960 |
+ |
p = n; |
961 |
+ |
} |
962 |
+ |
else { |
963 |
|
if (pred == null) |
964 |
|
tab[i] = n; |
965 |
|
else |
967 |
|
seg.decrementCount(); |
968 |
|
p = n; |
969 |
|
} |
965 |
– |
else { |
966 |
– |
pred = p; |
967 |
– |
p = n; |
968 |
– |
} |
970 |
|
} |
971 |
|
} |
972 |
|
} finally { |
1079 |
|
* </pre> |
1080 |
|
* |
1081 |
|
* except that the action is performed atomically. Some |
1082 |
< |
* attemmpted operations on this map by other threads may be |
1082 |
> |
* attempted operations on this map by other threads may be |
1083 |
|
* blocked while computation is in progress. Because this function |
1084 |
|
* is invoked within atomicity control, the computation should be |
1085 |
|
* short and simple. The most common usage is to construct a new |
1146 |
|
* return remove(key); |
1147 |
|
* </pre> |
1148 |
|
* |
1149 |
< |
* except that the action is performed atomically. Some attemmpted |
1149 |
> |
* except that the action is performed atomically. Some attempted |
1150 |
|
* operations on this map by other threads may be blocked while |
1151 |
|
* computation is in progress. |
1152 |
|
* |
3031 |
|
// Fenced store into segment table array. Unneeded when we have Fences |
3032 |
|
static final void storeNode(Node[] table, |
3033 |
|
int i, Node r) { |
3034 |
< |
_unsafe.putOrderedObject(table, (i << tableShift) + tableBase, r); |
3034 |
> |
long nodeOffset = ((long) i << tableShift) + tableBase; |
3035 |
> |
_unsafe.putOrderedObject(table, nodeOffset, r); |
3036 |
|
} |
3037 |
|
|
3038 |
|
static final void storeSegment(Segment[] segs, |
3039 |
|
int i, Segment s) { |
3040 |
< |
_unsafe.putOrderedObject(segs, (i << segmentsShift) + segmentsBase, s); |
3040 |
> |
long segmentOffset = ((long) i << segmentsShift) + segmentsBase; |
3041 |
> |
_unsafe.putOrderedObject(segs, segmentOffset, s); |
3042 |
|
} |
3043 |
|
|
3044 |
|
|