AtomicMarkableReference
maintains an object reference
along with a mark bit, that can be updated atomically.Implementation Note
This implementation maintains markable references by creating internal objects representing "boxed" [reference, boolean] pairs.
Modifier and Type | Class and Description |
---|---|
private static class |
Modifier and Type | Field and Description |
---|---|
private volatile AtomicMarkableReference. | |
private static final VarHandle |
Access | Constructor and Description |
---|---|
public | AtomicMarkableReference(V
the initial reference initialRef, boolean the initial mark initialMark)Creates a new |
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true if successfulthe expected value of the reference expectedReference, boolean the new value for the mark newMark)Atomically sets the value of the mark to the given update value
if the current reference is |
private boolean | |
public boolean | Returns: true if successfulthe expected value of the reference expectedReference, V the new value for the reference newReference, boolean the expected value of the mark expectedMark, boolean the new value for the mark newMark)Atomically sets the value of both the reference and mark
to the given update values if the
current reference is |
public V | Returns: the current value of the referencean array of size of at least one. On return,
markHolder)markHolder[0] will hold the value of the mark.Returns the current values of both the reference and the mark. |
public V | Returns: the current value of the referenceReturns the current value of the reference. |
public boolean | |
public void | set(V
the new value for the reference newReference, boolean the new value for the mark newMark)Unconditionally sets the value of both the reference and mark. |
public boolean | Returns: true if successfulthe expected value of the reference expectedReference, V the new value for the reference newReference, boolean the expected value of the mark expectedMark, boolean the new value for the mark newMark)Atomically sets the value of both the reference and mark to the
given update values if the current reference is |
pair | back to summary |
---|---|
private volatile AtomicMarkableReference. |
PAIR | back to summary |
---|---|
private static final VarHandle PAIR |
AtomicMarkableReference | back to summary |
---|---|
public AtomicMarkableReference(V initialRef, boolean initialMark) Creates a new
|
attemptMark | back to summary |
---|---|
public boolean attemptMark(V expectedReference, boolean newMark) Atomically sets the value of the mark to the given update value
if the current reference is
|
casPair | back to summary |
---|---|
private boolean casPair(AtomicMarkableReference. |
compareAndSet | back to summary |
---|---|
public boolean compareAndSet(V expectedReference, V newReference, boolean expectedMark, boolean newMark) Atomically sets the value of both the reference and mark
to the given update values if the
current reference is
|
get | back to summary |
---|---|
public V get(boolean[] markHolder) Returns the current values of both the reference and the mark.
Typical usage is
|
getReference | back to summary |
---|---|
public V getReference() Returns the current value of the reference.
|
isMarked | back to summary |
---|---|
public boolean isMarked() Returns the current value of the mark.
|
set | back to summary |
---|---|
public void set(V newReference, boolean newMark) Unconditionally sets the value of both the reference and mark.
|
weakCompareAndSet | back to summary |
---|---|
public boolean weakCompareAndSet(V expectedReference, V newReference, boolean expectedMark, boolean newMark) Atomically sets the value of both the reference and mark to the
given update values if the current reference is
|
Modifier and Type | Field and Description |
---|---|
pack-priv final boolean | |
pack-priv final T |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
pack-priv static <T> AtomicMarkableReference. |
mark | back to summary |
---|---|
pack-priv final boolean mark |
reference | back to summary |
---|---|
pack-priv final T reference |
Pair | back to summary |
---|---|
private Pair(T reference, boolean mark) |
of | back to summary |
---|---|
pack-priv static <T> AtomicMarkableReference. |