Class Cache.OriginThreadAwareFuture

  • All Implemented Interfaces:
    java.util.concurrent.Future<V>
    Enclosing class:
    Cache<K,​V>

    private class Cache.OriginThreadAwareFuture
    extends java.lang.Object
    implements java.util.concurrent.Future<V>
    Helper class, that remembers the future task origin thread, so that cycles could be detected. If any thread starts computation for given key and the same thread requests the computed value before the computation stops, a cycle is detected and registered cycle handler is called.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.FutureTask<V> future  
      private long threadId  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      boolean equals​(java.lang.Object obj)  
      V get()  
      V get​(long timeout, java.util.concurrent.TimeUnit unit)  
      int hashCode()  
      boolean isCancelled()  
      boolean isDone()  
      void run()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • threadId

        private volatile long threadId
      • future

        private final java.util.concurrent.FutureTask<V> future
    • Constructor Detail

      • OriginThreadAwareFuture

        OriginThreadAwareFuture​(Cache<K,​V> cache,
                                K key)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<V>
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<V>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<V>
      • get

        public V get()
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<V>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        public V get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<V>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • run

        public void run()