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:
java.io.Serializable
- Enclosing class:
- Iterables.LazyReference<T>
private final class Iterables.LazyReference.Sync extends java.util.concurrent.locks.AbstractQueuedSynchronizerSynchronization 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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ThrowableexceptionThe exception to throw from get()(package private) static intIGNOREDprivate TresultThe result to return from get()private java.lang.ThreadrunnerThe thread running task.private static longserialVersionUIDonly here to shut up the compiler warnings, the outer class is NOT serializable
-
Constructor Summary
Constructors Modifier Constructor Description privateSync()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcancel(boolean mayInterruptIfRunning)(package private) Tget()(package private) booleanisDone()private booleanranOrCancelled(int state)(package private) voidrun()(package private) voidset(T v)(package private) voidsetException(java.lang.Throwable t)protected 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, tryRelease
-
-
-
-
Field Detail
-
IGNORED
static final int IGNORED
- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
only here to shut up the compiler warnings, the outer class is NOT serializable- See Also:
- Constant Field Values
-
result
private T result
The result to return from get()
-
exception
private java.lang.Throwable exception
The exception to throw from get()
-
runner
private volatile java.lang.Thread 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.
-
-
Method Detail
-
ranOrCancelled
private boolean ranOrCancelled(int state)
-
tryAcquireShared
protected int tryAcquireShared(int ignore)
Implements AQS base acquire to succeed if ran or cancelled- Overrides:
tryAcquireSharedin classjava.util.concurrent.locks.AbstractQueuedSynchronizer
-
tryReleaseShared
protected boolean tryReleaseShared(int ignore)
Implements AQS base release to always signal after setting final done status by nulling runner thread.- Overrides:
tryReleaseSharedin classjava.util.concurrent.locks.AbstractQueuedSynchronizer
-
isDone
boolean isDone()
-
get
T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
set
void set(T v)
-
setException
void setException(java.lang.Throwable t)
-
cancel
void cancel(boolean mayInterruptIfRunning)
-
run
void run()
-
-