edu.emory.mathcs.backport.java.util.concurrent.atomic
public class AtomicMarkableReference extends Object
Implementation note. This implementation maintains markable references by creating internal objects representing "boxed" [reference, boolean] pairs.
Since: 1.5
Constructor Summary | |
---|---|
AtomicMarkableReference(Object initialRef, boolean initialMark)
Creates a new {@code AtomicMarkableReference} with the given
initial values.
|
Method Summary | |
---|---|
boolean | attemptMark(Object expectedReference, boolean newMark)
Atomically sets the value of the mark to the given update value
if the current reference is {@code ==} to the expected
reference. |
boolean | compareAndSet(Object expectedReference, Object 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 {@code ==} to the expected reference
and the current mark is equal to the expected mark.
|
Object | get(boolean[] markHolder)
Returns the current values of both the reference and the mark.
|
Object | getReference()
Returns the current value of the reference.
|
boolean | isMarked()
Returns the current value of the mark.
|
void | set(Object newReference, boolean newMark)
Unconditionally sets the value of both the reference and mark.
|
boolean | weakCompareAndSet(Object expectedReference, Object 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 {@code ==} to the expected reference
and the current mark is equal to the expected mark.
|
Parameters: initialRef the initial reference initialMark the initial mark
Parameters: expectedReference the expected value of the reference newMark the new value for the mark
Returns: true if successful
Parameters: expectedReference the expected value of the reference newReference the new value for the reference expectedMark the expected value of the mark newMark the new value for the mark
Returns: true if successful
Parameters: markHolder an array of size of at least one. On return, {@code markholder[0]} will hold the value of the mark.
Returns: the current value of the reference
Returns: the current value of the reference
Returns: the current value of the mark
Parameters: newReference the new value for the reference newMark the new value for the mark
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}.
Parameters: expectedReference the expected value of the reference newReference the new value for the reference expectedMark the expected value of the mark newMark the new value for the mark
Returns: true if successful