RichFuture

class RichFuture[T](fut: Future[T])

Useful enhancements to Future.

class Object
trait Matchable
class Any

Value members

Concrete methods

def failAfter(duration: FiniteDuration, msg: String): Future[T]

Cause this Future to fail with a FutureTimeoutException, with the given message, if it hasn't otherwise resolved in the given time. Note that it is an error if the Future resolves after this time -- that will cause a double-resolution. So this is mainly intended as a backstop to prevent hangs.

Cause this Future to fail with a FutureTimeoutException, with the given message, if it hasn't otherwise resolved in the given time. Note that it is an error if the Future resolves after this time -- that will cause a double-resolution. So this is mainly intended as a backstop to prevent hangs.

def notYet: Future[T]

Guarantees that this Future will not complete synchronously. If it is already completed, this returns a new Future that will return the same value after a minimal delay.

Guarantees that this Future will not complete synchronously. If it is already completed, this returns a new Future that will return the same value after a minimal delay.

This is mainly useful for simplifying code paths so that you don't have to deal with Futures that return synchronously only during, eg, testing.

def withTimeout(msg: String): Future[T]

Simpler version of failAfter(), which will fail after 1 second.

Simpler version of failAfter(), which will fail after 1 second.

def withTimeout: Future[T]

Simplest version of failAfter(): fails after 1 second, with a standard message. Useful for sanity-checking, especially in testing.

Simplest version of failAfter(): fails after 1 second, with a standard message. Useful for sanity-checking, especially in testing.