Promise

trait Promise[T]
Promise is an object which can be completed with a value or failed with an exception.
A promise should always eventually be completed, whether for success or failure, in order to avoid unintended resource retention for any associated Futures' callbacks or transformations.
Companion
object
Source
(source)
class Object
trait Matchable
class Any

Value members

Methods

def future: Future[T]
Future containing the value of this promise.
Source
(source)
Returns whether the promise has already been completed with a value or an exception.
Note: Using this method may result in non-deterministic concurrent programs.
Returns
true if the promise is already completed, false otherwise
Source
(source)
def complete(result: Try[T]): Promise[T]
Completes the promise with either an exception or a value.
Value Params
result
Either the value or the exception to complete the promise with. If the promise has already been fulfilled, failed or has timed out, calling this method will throw an IllegalStateException.
Source
(source)
def tryComplete(result: Try[T]): Boolean
Tries to complete the promise with either a value or the exception.
Note: Using this method may result in non-deterministic concurrent programs.
Returns
If the promise has already been completed returns false, or true otherwise.
Source
(source)
def completeWith(other: Future[T]): Promise[T]
Completes this promise with the specified future, once that future is completed.
Returns
This promise
Source
(source)
@deprecated("Since this method is semantically equivalent to `completeWith`, use that instead.", "2.13.0")
final def tryCompleteWith(other: Future[T]): Promise[T]
Attempts to complete this promise with the specified future, once that future is completed.
Returns
This promise
Source
(source)
def success(value: T): Promise[T]
Completes the promise with a value.
Value Params
value
The value to complete the promise with. If the promise has already been fulfilled, failed or has timed out, calling this method will throw an IllegalStateException.
Source
(source)
def trySuccess(value: T): Boolean
Tries to complete the promise with a value.
Note: Using this method may result in non-deterministic concurrent programs.
Returns
If the promise has already been completed returns false, or true otherwise.
Source
(source)
def failure(cause: Throwable): Promise[T]
Completes the promise with an exception.
Value Params
cause
The throwable to complete the promise with. If the throwable used to fail this promise is an error, a control exception or an interrupted exception, it will be wrapped as a cause within an ExecutionException which will fail the promise. If the promise has already been fulfilled, failed or has timed out, calling this method will throw an IllegalStateException.
Source
(source)
Tries to complete the promise with an exception.
Note: Using this method may result in non-deterministic concurrent programs.
Returns
If the promise has already been completed returns false, or true otherwise.
Source
(source)