Class 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.AbstractQueuedSynchronizer
    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

        java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Throwable exception
      The exception to throw from get()
      (package private) static int IGNORED  
      private T result
      The result to return from get()
      private java.lang.Thread runner
      The thread running task.
      private static long serialVersionUID
      only here to shut up the compiler warnings, the outer class is NOT serializable
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Sync()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void cancel​(boolean mayInterruptIfRunning)  
      (package private) T get()  
      (package private) boolean isDone()  
      private boolean ranOrCancelled​(int state)  
      (package private) void run()  
      (package private) void set​(T v)  
      (package private) void setException​(java.lang.Throwable t)  
      protected int tryAcquireShared​(int ignore)
      Implements AQS base acquire to succeed if ran or cancelled
      protected boolean tryReleaseShared​(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
      • Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer

        getExclusiveOwnerThread, setExclusiveOwnerThread
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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.
    • Constructor Detail

      • Sync

        private Sync()
    • 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:
        tryAcquireShared in class java.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:
        tryReleaseShared in class java.util.concurrent.locks.AbstractQueuedSynchronizer
      • isDone

        boolean isDone()
      • get

        T get()
        throws java.lang.InterruptedException,
              java.util.concurrent.ExecutionException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • set

        void set​(T v)
      • setException

        void setException​(java.lang.Throwable t)
      • cancel

        void cancel​(boolean mayInterruptIfRunning)
      • run

        void run()