Package play.libs

Class F.Promise<V>

  • All Implemented Interfaces:
    java.util.concurrent.Future<V>, F.Action<V>
    Direct Known Subclasses:
    F.Timeout
    Enclosing class:
    F

    public static class F.Promise<V>
    extends java.lang.Object
    implements java.util.concurrent.Future<V>, F.Action<V>
    • Field Detail

      • taskLock

        protected final java.util.concurrent.CountDownLatch taskLock
      • cancelled

        protected boolean cancelled
      • invoked

        protected boolean invoked
      • result

        protected V result
      • exception

        protected java.lang.Throwable exception
    • Constructor Detail

      • Promise

        public Promise()
    • Method Detail

      • 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>
      • getOrNull

        public V getOrNull()
      • 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
      • invoke

        public void invoke​(V result)
        Specified by:
        invoke in interface F.Action<V>
      • invokeWithException

        public void invokeWithException​(java.lang.Throwable t)
      • invokeWithResultOrException

        protected void invokeWithResultOrException​(V result,
                                                   java.lang.Throwable t)
      • onRedeem

        public void onRedeem​(F.Action<F.Promise<V>> callback)
        Registers an action that is to be invoked after this promise is invoked. You may register more than one "onRedeem" callback. Each registered callback is guaranteed to be invoked exactly once after this promise has been invoked.

        The thread from which the "onRedeem" callback is invoked is not defined.

        Parameters:
        callback - The callback action to invoke when this promise.
      • waitAll

        public static <T> F.Promise<java.util.List<T>> waitAll​(F.Promise<T>... promises)
      • waitAll

        public static <T> F.Promise<java.util.List<T>> waitAll​(java.util.Collection<F.Promise<T>> promises)