1 *java.util.concurrent.atomic.AtomicMarkableReference* *AtomicMarkableReference*
3 public class AtomicMarkableReference<V>
4 extends |java.lang.Object|
6 |java.util.concurrent.atomic.AtomicMarkableReference_Description|
7 |java.util.concurrent.atomic.AtomicMarkableReference_Fields|
8 |java.util.concurrent.atomic.AtomicMarkableReference_Constructors|
9 |java.util.concurrent.atomic.AtomicMarkableReference_Methods|
11 ================================================================================
13 *java.util.concurrent.atomic.AtomicMarkableReference_Constructors*
14 |java.util.concurrent.atomic.AtomicMarkableReference(V,boolean)|Creates a newAt
16 *java.util.concurrent.atomic.AtomicMarkableReference_Methods*
17 |java.util.concurrent.atomic.AtomicMarkableReference.attemptMark(V,boolean)|Ato
18 |java.util.concurrent.atomic.AtomicMarkableReference.compareAndSet(V,V,boolean,boolean)|
19 |java.util.concurrent.atomic.AtomicMarkableReference.get(boolean[])|Returns the
20 |java.util.concurrent.atomic.AtomicMarkableReference.getReference()|Returns the
21 |java.util.concurrent.atomic.AtomicMarkableReference.isMarked()|Returns the cur
22 |java.util.concurrent.atomic.AtomicMarkableReference.set(V,boolean)|Uncondition
23 |java.util.concurrent.atomic.AtomicMarkableReference.weakCompareAndSet(V,V,boolean,boolean)|
25 *java.util.concurrent.atomic.AtomicMarkableReference_Description*
27 AnAtomicMarkableReferencemaintains an object reference along with a mark bit,
28 that can be updated atomically.
30 Implementation note. This implementation maintains markable references by
31 creating internal objects representing "boxed" [reference, boolean] pairs.
35 *java.util.concurrent.atomic.AtomicMarkableReference(V,boolean)*
37 public AtomicMarkableReference(
41 Creates a newAtomicMarkableReferencewith the given initial values.
43 initialRef - the initial reference
44 initialMark - the initial mark
46 *java.util.concurrent.atomic.AtomicMarkableReference.attemptMark(V,boolean)*
48 public boolean attemptMark(
52 Atomically sets the value of the mark to the given update value if the current
53 reference is==to the expected reference. Any given invocation of this operation
54 may fail (returnfalse) spuriously, but repeated invocation when the current
55 value holds the expected value and no other thread is also attempting to set
56 the value will eventually succeed.
59 expectedReference - the expected value of the reference
60 newMark - the new value for the mark
62 Returns: true if successful
64 *java.util.concurrent.atomic.AtomicMarkableReference.compareAndSet(V,V,boolean,boolean)*
66 public boolean compareAndSet(
72 Atomically sets the value of both the reference and mark to the given update
73 values if the current reference is==to the expected reference and the current
74 mark is equal to the expected mark.
77 expectedReference - the expected value of the reference
78 newReference - the new value for the reference
79 expectedMark - the expected value of the mark
80 newMark - the new value for the mark
82 Returns: true if successful
84 *java.util.concurrent.atomic.AtomicMarkableReference.get(boolean[])*
86 public |V| get(boolean[] markHolder)
88 Returns the current values of both the reference and the mark. Typical usage
89 isboolean[1] holder; ref = v.get(holder);.
92 markHolder - an array of size of at least one. On return, {@code markholder[0]} will hold
93 the value of the mark.
95 Returns: the current value of the reference
97 *java.util.concurrent.atomic.AtomicMarkableReference.getReference()*
99 public |V| getReference()
101 Returns the current value of the reference.
105 Returns: the current value of the reference
107 *java.util.concurrent.atomic.AtomicMarkableReference.isMarked()*
109 public boolean isMarked()
111 Returns the current value of the mark.
115 Returns: the current value of the mark
117 *java.util.concurrent.atomic.AtomicMarkableReference.set(V,boolean)*
123 Unconditionally sets the value of both the reference and mark.
126 newReference - the new value for the reference
127 newMark - the new value for the mark
129 *java.util.concurrent.atomic.AtomicMarkableReference.weakCompareAndSet(V,V,boolean,boolean)*
131 public boolean weakCompareAndSet(
134 boolean expectedMark,
137 Atomically sets the value of both the reference and mark to the given update
138 values if the current reference is==to the expected reference and the current
139 mark is equal to the expected mark.
141 May fail spuriously and does not provide ordering guarantees, so is only rarely
142 an appropriate alternative tocompareAndSet.
145 expectedReference - the expected value of the reference
146 newReference - the new value for the reference
147 expectedMark - the expected value of the mark
148 newMark - the new value for the mark
150 Returns: true if successful