AbstractQueuedSynchronizer
in
which synchronization state is maintained as a long
.
This class has exactly the same structure, properties, and methods
as AbstractQueuedSynchronizer
with the exception
that all state-related parameters and results are defined
as long
rather than int
. This class
may be useful when creating synchronizers such as
multilevel locks and barriers that require
64 bits of state.
See AbstractQueuedSynchronizer
for usage
notes and examples.
Modifier and Type | Class and Description |
---|---|
pack-priv static class | |
public class | AbstractQueuedLongSynchronizer.
Condition implementation for a |
pack-priv static class | |
pack-priv abstract static class | AbstractQueuedLongSynchronizer.
CLH Nodes |
pack-priv static class |
Modifier and Type | Field and Description |
---|---|
pack-priv static final int | |
pack-priv static final int | |
private transient volatile AbstractQueuedLongSynchronizer. | head
Head of the wait queue, lazily initialized. |
private static final long | |
private static final long | |
private volatile long | state
The synchronization state. |
private static final long | |
private transient volatile AbstractQueuedLongSynchronizer. | tail
Tail of the wait queue. |
private static final long | |
private static final Unsafe | |
pack-priv static final int |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
pack-priv final int | Returns: positive if acquired, 0 if timed out, negative if interruptednull unless a reacquiring Condition node,the acquire argument arg, boolean true if shared mode else exclusive shared, boolean if abort and return negative on interrupt interruptible, boolean if true use timed waits timed, long if timed, the System.nanoTime value to timeout time)Main acquire method, invoked by all exported acquire methods. |
public final void | acquire(long
the acquire argument. This value is conveyed to
arg)tryAcquire but is otherwise uninterpreted and
can represent anything you like.Acquires in exclusive mode, ignoring interrupts. |
public final void | acquireInterruptibly(long
the acquire argument. This value is conveyed to
arg)tryAcquire but is otherwise uninterpreted and
can represent anything you like.Acquires in exclusive mode, aborting if interrupted. |
private int | acquireOnOOME(boolean shared, long arg)
Spin-waits with backoff; used only upon OOME failures during acquire. |
public final void | acquireShared(long
the acquire argument. This value is conveyed to
arg)tryAcquireShared but is otherwise uninterpreted
and can represent anything you like.Acquires in shared mode, ignoring interrupts. |
public final void | acquireSharedInterruptibly(long
the acquire argument.
This value is conveyed to arg)tryAcquireShared but is
otherwise uninterpreted and can represent anything
you like.Acquires in shared mode, aborting if interrupted. |
pack-priv final boolean | apparentlyFirstQueuedIsExclusive()
Returns |
private int | cancelAcquire(AbstractQueuedLongSynchronizer.
the node (may be null if cancelled before enqueuing) node,true if thread interrupted interrupted, boolean if should report interruption vs reset interruptible)Cancels an ongoing attempt to acquire. |
private boolean | |
private void | cleanQueue()
Possibly repeatedly traverses from tail, unsplicing cancelled nodes until none are found. |
protected final boolean | Returns: true if successful. False return indicates that the actual
value was not equal to the expected value.the expected value expect, long the new value update)Atomically sets synchronization state to the given updated value if the current state value equals the expected value. |
pack-priv final void | |
public final Collection | Returns: the collection of threadsReturns a collection containing threads that may be waiting to acquire in exclusive mode. |
public final Thread | Returns: the first (longest-waiting) thread in the queue, ornull if no threads are currently queuedReturns the first (longest-waiting) thread in the queue, or
|
public final Collection | Returns: the collection of threadsReturns a collection containing threads that may be waiting to acquire. |
public final int | Returns: the estimated number of threads waiting to acquireReturns an estimate of the number of threads waiting to acquire. |
public final Collection | Returns: the collection of threadsReturns a collection containing threads that may be waiting to acquire in shared mode. |
protected final long | |
public final Collection | Returns: the collection of threadsthe condition conditionReturns a collection containing those threads that may be waiting on the given condition associated with this synchronizer. |
public final int | Returns: the estimated number of waiting threadsthe condition conditionReturns an estimate of the number of threads waiting on the given condition associated with this synchronizer. |
public final boolean | Returns: true if there has ever been contentionQueries whether any threads have ever contended to acquire this synchronizer; that is, if an acquire method has ever blocked. |
public final boolean | Returns: true if there is a queued thread preceding the
current thread, and false if the current thread
is at the head of the queue or the queue is emptyQueries whether any threads have been waiting to acquire longer than the current thread. |
public final boolean | Returns: true if there may be other threads waiting to acquireQueries whether any threads are waiting to acquire. |
public final boolean | Returns: true if there are any waiting threadsthe condition conditionQueries whether any threads are waiting on the given condition associated with this synchronizer. |
pack-priv final boolean | isEnqueued(AbstractQueuedLongSynchronizer.
Returns true if node is found in traversal from tail |
protected boolean | Returns: true if synchronization is held exclusively;
false otherwiseReturns |
public final boolean | |
public final boolean | Returns: true if ownedthe condition conditionQueries whether the given ConditionObject uses this synchronizer as its lock. |
public final boolean | Returns: the value returned fromtryRelease the release argument. This value is conveyed to
arg)tryRelease but is otherwise uninterpreted and
can represent anything you like.Releases in exclusive mode. |
public final boolean | Returns: the value returned fromtryReleaseShared the release argument. This value is conveyed to
arg)tryReleaseShared but is otherwise uninterpreted
and can represent anything you like.Releases in shared mode. |
protected final void | |
private static void | signalNext(AbstractQueuedLongSynchronizer.
Wakes up the successor of given node, if one exists, and unsets its WAITING status to avoid park race. |
private static void | |
public String | Returns: a string identifying this synchronizer, as well as its stateOverrides java. Returns a string identifying this synchronizer, as well as its state. |
protected boolean | Returns: true if successful. Upon success, this object has
been acquired.the acquire argument. This value is always the one
passed to an acquire method, or is the value saved on entry
to a condition wait. The value is otherwise uninterpreted
and can represent anything you like. arg)Attempts to acquire in exclusive mode. |
public final boolean | Returns: true if acquired; false if timed outthe acquire argument. This value is conveyed to
arg, long tryAcquire but is otherwise uninterpreted and
can represent anything you like.the maximum number of nanoseconds to wait nanosTimeout)Attempts to acquire in exclusive mode, aborting if interrupted, and failing if the given timeout elapses. |
protected long | Returns: a negative value on failure; zero if acquisition in shared mode succeeded but no subsequent shared-mode acquire can succeed; and a positive value if acquisition in shared mode succeeded and subsequent shared-mode acquires might also succeed, in which case a subsequent waiting thread must check availability. (Support for three different return values enables this method to be used in contexts where acquires only sometimes act exclusively.) Upon success, this object has been acquired.the acquire argument. This value is always the one
passed to an acquire method, or is the value saved on entry
to a condition wait. The value is otherwise uninterpreted
and can represent anything you like. arg)Attempts to acquire in shared mode. |
public final boolean | Returns: true if acquired; false if timed outthe acquire argument. This value is conveyed to
arg, long tryAcquireShared but is otherwise uninterpreted
and can represent anything you like.the maximum number of nanoseconds to wait nanosTimeout)Attempts to acquire in shared mode, aborting if interrupted, and failing if the given timeout elapses. |
private AbstractQueuedLongSynchronizer. | |
protected boolean | Returns: true if this object is now in a fully released
state, so that any waiting threads may attempt to acquire;
and false otherwise.the release argument. This value is always the one
passed to a release method, or the current state value upon
entry to a condition wait. The value is otherwise
uninterpreted and can represent anything you like. arg)Attempts to set the state to reflect a release in exclusive mode. |
protected boolean | Returns: true if this release of shared mode may permit a
waiting acquire (shared or exclusive) to succeed; and
false otherwisethe release argument. This value is always the one
passed to a release method, or the current state value upon
entry to a condition wait. The value is otherwise
uninterpreted and can represent anything you like. arg)Attempts to set the state to reflect a release in shared mode. |