Package io.atlassian.fugue
Class Iterables.LazyReference.Sync
java.lang.Object
java.util.concurrent.locks.AbstractOwnableSynchronizer
java.util.concurrent.locks.AbstractQueuedSynchronizer
io.atlassian.fugue.Iterables.LazyReference.Sync
- All Implemented Interfaces:
Serializable
- Enclosing class:
Iterables.LazyReference<T>
Synchronization control for LazyReference. Note that this must be a
non-static inner class in order to invoke the protected
{code}create{/code} method. Taken from FutureTask AQS implementation and
pruned to be as compact as possible.
Uses AQS sync state to represent run status.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ThrowableThe exception to throw from get()(package private) static final intprivate TThe result to return from get()private ThreadThe thread running task.private static final longonly here to shut up the compiler warnings, the outer class is NOT serializable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidcancel(boolean mayInterruptIfRunning) (package private) Tget()(package private) booleanisDone()private booleanranOrCancelled(int state) (package private) voidrun()(package private) void(package private) voidprotected inttryAcquireShared(int ignore) Implements AQS base acquire to succeed if ran or cancelledprotected booleantryReleaseShared(int ignore) Implements AQS base release to always signal after setting final done status by nulling runner thread.Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryReleaseMethods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer
getExclusiveOwnerThread, setExclusiveOwnerThread
-
Field Details
-
IGNORED
static final int IGNORED- See Also:
-
serialVersionUID
private static final long serialVersionUIDonly here to shut up the compiler warnings, the outer class is NOT serializable- See Also:
-
result
The result to return from get() -
exception
The exception to throw from get() -
runner
The thread running task. When nulled after set/cancel, this indicates that the results are accessible. Must be volatile, to ensure visibility upon completion.
-
-
Constructor Details
-
Sync
private Sync()
-
-
Method Details
-
ranOrCancelled
private boolean ranOrCancelled(int state) -
isDone
boolean isDone() -
get
-
set
-
setException
-
cancel
void cancel(boolean mayInterruptIfRunning) -
run
void run()
-