akka.dispatch

DefaultPromise

class DefaultPromise[T] extends AbstractPromise with Promise[T]

The default concrete Future implementation.

Self Type
DefaultPromise[T]
Linear Supertypes
Promise[T], Future[T], Awaitable[T], AbstractPromise, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. DefaultPromise
  2. Promise
  3. Future
  4. Awaitable
  5. AbstractPromise
  6. AnyRef
  7. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DefaultPromise()(implicit executor: ExecutionContext)

Type Members

  1. final class FutureWithFilter[+A] extends AnyRef

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]]

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

    Definition Classes
    Promise
  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]): DefaultPromise.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

    Definition Classes
    Promise
    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]): DefaultPromise.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.

    Definition Classes
    Promise
  14. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  16. implicit val executor: ExecutionContext

    Definition Classes
    DefaultPromiseFuture
  17. 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
  18. final def failure(exception: Throwable): DefaultPromise.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

    Definition Classes
    Promise
  19. 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
  20. 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
  21. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. 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
  23. 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
  24. def future: Future[T]

    Returns the Future associated with this Promise

    Returns the Future associated with this Promise

    Definition Classes
    Promise
  25. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  26. final def getState: AnyRef

    Attributes
    protected
    Annotations
    @inline()
  27. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  28. def isCompleted(): Boolean

    Tests whether this Future has been completed.

    Tests whether this Future has been completed.

    Definition Classes
    DefaultPromiseFuture
  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. 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
  31. 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
  32. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  35. def onComplete[U](func: (Either[Throwable, T]) ⇒ U): DefaultPromise.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
    DefaultPromiseFuture
  36. final def onFailure[U](pf: PartialFunction[Throwable, U]): DefaultPromise.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
  37. final def onSuccess[U](pf: PartialFunction[T, U]): DefaultPromise.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
  38. def ready(atMost: Duration)(implicit permit: CanAwait): DefaultPromise.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
    DefaultPromiseAwaitable
    Annotations
    @throws( classOf[TimeoutException] )
  39. 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
  40. 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
  41. final def resolve[X](source: Either[Throwable, X]): Either[Throwable, X]

    Attributes
    protected
    Definition Classes
    Future
  42. 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
    DefaultPromiseAwaitable
    Annotations
    @throws( classOf[Exception] )
  43. final def success(result: T): DefaultPromise.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

    Definition Classes
    Promise
  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toString(): String

    Definition Classes
    AnyRef → Any
  46. final def tryAwait(atMost: Duration): Boolean

    Attributes
    protected
  47. 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

    Definition Classes
    DefaultPromisePromise
  48. final def updateState(oldState: AnyRef, newState: AnyRef): Boolean

    Attributes
    protected
    Annotations
    @inline()
  49. 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
    DefaultPromiseFuture
  50. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. 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
  54. 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]]

    Definition Classes
    Promise
    Annotations
    @deprecated
    Deprecated

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

Inherited from Promise[T]

Inherited from Future[T]

Inherited from Awaitable[T]

Inherited from AbstractPromise

Inherited from AnyRef

Inherited from Any