akka.dispatch

Promise

trait Promise[T] extends Future[T]

Essentially this is the Promise (or write-side) of a Future (read-side).

Linear Supertypes
Future[T], Awaitable[T], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Promise
  2. Future
  3. Awaitable
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Type Members

  1. final class FutureWithFilter[+A] extends AnyRef

Abstract Value Members

  1. implicit abstract def executor: ExecutionContext

    Attributes
    protected
    Definition Classes
    Future
  2. abstract def isCompleted: Boolean

    Tests whether this Future has been completed.

    Tests whether this Future has been completed.

    Definition Classes
    Future
  3. abstract def onComplete[U](func: (Either[Throwable, T]) ⇒ U): Promise.this.type

    When this Future is completed, apply the provided function to the Future.

    When this Future is completed, apply the provided function to the Future. If the Future has already been completed, this will apply immediately. Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  4. abstract def ready(atMost: Duration)(implicit permit: CanAwait): Promise.this.type

    Should throw java.util.concurrent.TimeoutException if times out This method should not be called directly.

    Should throw java.util.concurrent.TimeoutException if times out This method should not be called directly.

    Definition Classes
    Awaitable
    Annotations
    @throws( classOf[TimeoutException] )
  5. abstract def result(atMost: Duration)(implicit permit: CanAwait): T

    Throws exceptions if cannot produce a T within the specified time This method should not be called directly.

    Throws exceptions if cannot produce a T within the specified time This method should not be called directly.

    Definition Classes
    Awaitable
    Annotations
    @throws( classOf[Exception] )
  6. abstract def tryComplete(value: Either[Throwable, T]): Boolean

    Completes this Promise with the specified result, if not already completed.

    Completes this Promise with the specified result, if not already completed.

    returns

    whether this call completed the Promise

  7. abstract def value: Option[Either[Throwable, T]]

    The contained value of this Future.

    The contained value of this Future. Before this Future is completed the value will be None. After completion the value will be Some(Right(t)) if it contains a valid result, or Some(Left(error)) if it contains an exception.

    Definition Classes
    Future

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def <<(other: Future[T]): akka.dispatch.Future[T] @util.continuations.package.cps[akka.dispatch.Future[Any]]

  5. final def <<(value: T): akka.dispatch.Future[T] @util.continuations.package.cps[akka.dispatch.Future[Any]]

  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def andThen[U](pf: PartialFunction[Either[Throwable, T], U]): Future[T]

    Returns a new Future that will contain the completed result of this Future, and which will invoke the supplied PartialFunction when completed.

    Returns a new Future that will contain the completed result of this Future, and which will invoke the supplied PartialFunction when completed.

    This allows for establishing order of side-effects.

     Future { 5 } andThen {
       case something => assert(something is awesome)
     } andThen {
       case Left(t) => handleProblem(t)
       case Right(v) => dealWithSuccess(v)
     }
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  9. def apply(): T @util.continuations.package.cps[akka.dispatch.Future[Any]]

    For use only within a Future.

    For use only within a Future.flow block or another compatible Delimited Continuations reset block.

    Returns the result of this Future without blocking, by suspending execution and storing it as a continuation until the result is available.

    Definition Classes
    Future
  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  12. final def complete(value: Either[Throwable, T]): Promise.this.type

    Completes this Promise with the specified result, if not already completed.

    Completes this Promise with the specified result, if not already completed.

    returns

    this

    Exceptions thrown
    IllegalStateException

    if already completed, this is to aid in debugging of complete-races, use tryComplete to do a conditional complete.

  13. final def completeWith(other: Future[T]): Promise.this.type

    Completes this Promise with the specified other Future, when that Future is completed, unless this Promise has already been completed.

    Completes this Promise with the specified other Future, when that Future is completed, unless this Promise has already been completed.

    returns

    this.

  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. final def failed: Future[Throwable]

    Returns a failure projection of this Future If this becomes completed with a failure, that failure will be the success of the returned Future If this becomes completed with a result, then the returned future will fail with a NoSuchElementException

    Returns a failure projection of this Future If this becomes completed with a failure, that failure will be the success of the returned Future If this becomes completed with a result, then the returned future will fail with a NoSuchElementException

    Definition Classes
    Future
  17. final def failure(exception: Throwable): Promise.this.type

    Completes this Promise with the specified exception, if not already completed.

    Completes this Promise with the specified exception, if not already completed.

    returns

    this

  18. def fallbackTo[U >: T](that: Future[U]): Future[U]

    Returns a new Future that will either hold the successful value of this Future, or, it this Future fails, it will hold the result of "that" Future.

    Returns a new Future that will either hold the successful value of this Future, or, it this Future fails, it will hold the result of "that" Future.

    Definition Classes
    Future
  19. final def filter(pred: (T) ⇒ Boolean): Future[T]

    Returns a new Future that will hold the successful result of this Future if it matches the given predicate, if it doesn't match, the resulting Future will be a failed Future with a MatchError, of if this Future fails, that failure will be propagated to the returned Future

    Returns a new Future that will hold the successful result of this Future if it matches the given predicate, if it doesn't match, the resulting Future will be a failed Future with a MatchError, of if this Future fails, that failure will be propagated to the returned Future

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  20. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  21. final def flatMap[A](f: (T) ⇒ Future[A]): Future[A]

    Creates a new Future by applying a function to the successful result of this Future, and returns the result of the function as the new Future.

    Creates a new Future by applying a function to the successful result of this Future, and returns the result of the function as the new Future. If this Future is completed with an exception then the new Future will also contain this exception. Example:

    val future1 = for {
      a: Int    <- actor ? "Hello" // returns 5
      b: String <- actor ? a       // returns "10"
      c: String <- actor ? 7       // returns "14"
    } yield b + "-" + c
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  22. final def foreach[U](f: (T) ⇒ U): Unit

    Same as onSuccess { case r => f(r) } but is also used in for-comprehensions

    Same as onSuccess { case r => f(r) } but is also used in for-comprehensions

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  23. def future: Future[T]

    Returns the Future associated with this Promise

  24. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  25. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. final def map[A](f: (T) ⇒ A): Future[A]

    Creates a new Future by applying a function to the successful result of this Future.

    Creates a new Future by applying a function to the successful result of this Future. If this Future is completed with an exception then the new Future will also contain this exception. Example:

    val future1 = for {
      a: Int    <- actor ? "Hello" // returns 5
      b: String <- actor ? a       // returns "10"
      c: String <- actor ? 7       // returns "14"
    } yield b + "-" + c
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  28. final def mapTo[A](implicit m: Manifest[A]): Future[A]

    Creates a new Future[A] which is completed with this Future's result if that conforms to A's erased type or a ClassCastException otherwise.

    Creates a new Future[A] which is completed with this Future's result if that conforms to A's erased type or a ClassCastException otherwise.

    When used from Java, to create the Manifest, use: import static akka.japi.Util.manifest; future.mapTo(manifest(MyClass.class));

    Definition Classes
    Future
  29. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  32. final def onFailure[U](pf: PartialFunction[Throwable, U]): Promise.this.type

    When the future is completed with an exception, apply the provided PartialFunction to the exception.

    When the future is completed with an exception, apply the provided PartialFunction to the exception. See onComplete for more details.

      future onFailure {
        case NumberFormatException ⇒ target ! "wrong format"
      }
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  33. final def onSuccess[U](pf: PartialFunction[T, U]): Promise.this.type

    When the future is completed with a valid result, apply the provided PartialFunction to the result.

    When the future is completed with a valid result, apply the provided PartialFunction to the result. See onComplete for more details.

      future onSuccess {
        case Foo ⇒ target ! "foo"
        case Bar ⇒ target ! "bar"
      }
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  34. final def recover[A >: T](pf: PartialFunction[Throwable, A]): Future[A]

    Creates a new Future that will handle any matching Throwable that this Future might contain.

    Creates a new Future that will handle any matching Throwable that this Future might contain. If there is no match, or if this Future contains a valid result then the new Future will contain the same. Example:

    Future(6 / 0) recover { case e: ArithmeticException ⇒ 0 } // result: 0
    Future(6 / 0) recover { case e: NotFoundException   ⇒ 0 } // result: exception
    Future(6 / 2) recover { case e: ArithmeticException ⇒ 0 } // result: 3
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  35. def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]]): Future[U]

    Returns a new Future that will, in case this future fails, be completed with the resulting Future of the given PartialFunction, if the given PartialFunction matches the failure of the original Future.

    Returns a new Future that will, in case this future fails, be completed with the resulting Future of the given PartialFunction, if the given PartialFunction matches the failure of the original Future.

    If the PartialFunction throws, that Throwable will be propagated to the returned Future.

    Example:

     val f = Future { Int.MaxValue }
     Future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue
    

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  36. final def resolve[X](source: Either[Throwable, X]): Either[Throwable, X]

    Attributes
    protected
    Definition Classes
    Future
  37. final def success(result: T): Promise.this.type

    Completes this Promise with the specified result, if not already completed.

    Completes this Promise with the specified result, if not already completed.

    returns

    this

  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  39. def toString(): String

    Definition Classes
    AnyRef → Any
  40. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  41. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  42. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  43. final def withFilter(p: (T) ⇒ Boolean): FutureWithFilter[T]

    Used by for-comprehensions

    Used by for-comprehensions

    Note: the callback function may (and probably will) run in another thread, and therefore should not refer to any unsynchronized state. In particular, if using this method from an actor, do not access the state of the actor from the callback function. Promise.completeWith, PipeableFuture.pipeTo, and Future.fallbackTo are some methods to consider using when possible, to avoid concurrent callbacks.

    Definition Classes
    Future
  44. def zip[U](that: Future[U]): Future[(T, U)]

    returns

    a new Future that will contain a tuple containing the successful result of this and that Future. If this or that fail, they will race to complete the returned Future with their failure. The returned Future will not be completed if neither this nor that are completed.

    Definition Classes
    Future

Deprecated Value Members

  1. final def <<(stream: PromiseStreamOut[T]): akka.dispatch.Future[T] @util.continuations.package.cps[akka.dispatch.Future[Any]]

    Annotations
    @deprecated
    Deprecated

    (Since version 2.0.2) Was never officially supported or documented, will be removed in Akka 2.1

Inherited from Future[T]

Inherited from Awaitable[T]

Inherited from AnyRef

Inherited from Any