1 *java.util.concurrent.atomic.AtomicStampedReference* *AtomicStampedReference* An
3 public class AtomicStampedReference
4 extends |java.lang.Object|
6 |java.util.concurrent.atomic.AtomicStampedReference_Description|
7 |java.util.concurrent.atomic.AtomicStampedReference_Fields|
8 |java.util.concurrent.atomic.AtomicStampedReference_Constructors|
9 |java.util.concurrent.atomic.AtomicStampedReference_Methods|
11 ================================================================================
13 *java.util.concurrent.atomic.AtomicStampedReference_Constructors*
14 |java.util.concurrent.atomic.AtomicStampedReference(V,int)|Creates a new Atomic
16 *java.util.concurrent.atomic.AtomicStampedReference_Methods*
17 |java.util.concurrent.atomic.AtomicStampedReference.attemptStamp(V,int)|Atomica
18 |java.util.concurrent.atomic.AtomicStampedReference.compareAndSet(V,V,int,int)|
19 |java.util.concurrent.atomic.AtomicStampedReference.get(int[])|Returns the curr
20 |java.util.concurrent.atomic.AtomicStampedReference.getReference()|Returns the
21 |java.util.concurrent.atomic.AtomicStampedReference.getStamp()|Returns the curr
22 |java.util.concurrent.atomic.AtomicStampedReference.set(V,int)|Unconditionally
23 |java.util.concurrent.atomic.AtomicStampedReference.weakCompareAndSet(V,V,int,int)|
25 *java.util.concurrent.atomic.AtomicStampedReference_Description*
27 An AtomicStampedReference maintains an object reference along with an integer
28 "stamp", that can be updated atomically.
30 Implementation note. This implementation maintains stamped references by
31 creating internal objects representing "boxed" [reference, integer] pairs.
34 *java.util.concurrent.atomic.AtomicStampedReference(V,int)*
36 public AtomicStampedReference(
37 java.lang.Object initialRef,
40 Creates a new AtomicStampedReference with the given initial values.
42 initialRef - the initial reference
43 initialStamp - the initial stamp
45 *java.util.concurrent.atomic.AtomicStampedReference.attemptStamp(V,int)*
47 public boolean attemptStamp(
48 java.lang.Object expectedReference,
51 Atomically sets the value of the stamp to the given update value if the current
52 reference is == to the expected reference. Any given invocation of this
53 operation may fail (return false) spuriously, but repeated invocation when the
54 current value holds the expected value and no other thread is also attempting
55 to set the value will eventually succeed.
57 expectedReference - the expected value of the reference
58 newStamp - the new value for the stamp
60 Returns: true if successful
61 *java.util.concurrent.atomic.AtomicStampedReference.compareAndSet(V,V,int,int)*
63 public boolean compareAndSet(
64 java.lang.Object expectedReference,
65 java.lang.Object newReference,
69 Atomically sets the value of both the reference and stamp to the given update
70 values if the current reference is == to the expected reference and the current
71 stamp is equal to the expected stamp.
73 expectedReference - the expected value of the reference
74 newReference - the new value for the reference
75 expectedStamp - the expected value of the stamp
76 newStamp - the new value for the stamp
78 Returns: true if successful
79 *java.util.concurrent.atomic.AtomicStampedReference.get(int[])*
81 public |java.lang.Object| get(int[] stampHolder)
83 Returns the current values of both the reference and the stamp. Typical usage
84 is int[1] holder; ref = v.get(holder); .
86 stampHolder - an array of size of at least one. On return, stampholder[0] will hold the value
89 Returns: the current value of the reference
90 *java.util.concurrent.atomic.AtomicStampedReference.getReference()*
92 public |java.lang.Object| getReference()
94 Returns the current value of the reference.
97 Returns: the current value of the reference
98 *java.util.concurrent.atomic.AtomicStampedReference.getStamp()*
100 public int getStamp()
102 Returns the current value of the stamp.
105 Returns: the current value of the stamp
106 *java.util.concurrent.atomic.AtomicStampedReference.set(V,int)*
109 java.lang.Object newReference,
112 Unconditionally sets the value of both the reference and stamp.
114 newReference - the new value for the reference
115 newStamp - the new value for the stamp
117 *java.util.concurrent.atomic.AtomicStampedReference.weakCompareAndSet(V,V,int,int)*
119 public boolean weakCompareAndSet(
120 java.lang.Object expectedReference,
121 java.lang.Object newReference,
125 Atomically sets the value of both the reference and stamp to the given update
126 values if the current reference is == to the expected reference and the current
127 stamp is equal to the expected stamp. Any given invocation of this operation
128 may fail (return false) spuriously, but repeated invocation when the current
129 value holds the expected value and no other thread is also attempting to set
130 the value will eventually succeed.
132 expectedReference - the expected value of the reference
133 newReference - the new value for the reference
134 expectedStamp - the expected value of the stamp
135 newStamp - the new value for the stamp
137 Returns: true if successful