Companion object for Timed
typeclass that offers three implicit providers: one for FutureOutcome
,
one for Future
of any type, and one for any other type.
The details are in the documentation for the implicit providers themselves (methods timed
, timedFutureOf
,
and timedFutureOutcome
), but in short if a time limit is exceeded:
-
if the type
T
inTimed[T]
isFutureOutcome
theFutureOutcome
returned bytimeoutAfter
will result in eitherFailed
orCanceled
-
if the type is
Future[U]
, theFuture[U]
returned bytimeoutAfter
will fail with either aTestFailedDueToTimeoutException
or aTestCanceledException
. -
otherwise, the
timeoutAfter
method will itself complete abruptly with eitherTestFailedDueToTimeoutException
orTestCanceledException.
- Companion:
- class
Implicits
Implicits
Implicit method that provides Timed
implementation for any T
.
Implicit method that provides Timed
implementation for any T
.
If the function completes before the timeout expires:
-
If the function returns normally, this method will return normally.
-
If the function completes abruptly with an exception, this method will complete abruptly with that same exception.
If the function completes after the timeout expires:
-
If the function returns normally, this method will complete abruptly with a
StackDepthException
created fromexceptionFun
. -
If the function completes abruptly with an exception, this method will complete abruptly with a
StackDepthException
created fromexceptionFun
that includes the exception thrown by the function as its cause.
This implementation will start a timer that when the time limit is exceeded while the passed in function f
is still running, it will attempt to call the passed in Signaler
to signal/interrupt the running function f
.
Implicit method that provides Timed
implementation for any Future[T]
.
Implicit method that provides Timed
implementation for any Future[T]
.
If the asynchronous function completes before the timeout expires:
-
If the function returns normally, the
Future
will be completed with the return value of the function. -
If the function completes abruptly with an exception, this method will complete the
Future
with that same exception.
If the asynchronous function completes after the timeout expires:
-
If the function returns normally, this method will complete the
Future
with aStackDepthException
created fromexceptionFun
. -
If the function completes abruptly with an exception, this method will complete the
Future
with aStackDepthException
created fromexceptionFun
that includes the exception thrown by the function as its cause.
This implementation will start a timer that when the time limit is exceeded while the passed in asynchronous function f
is still running, it will attempt to call the passed in Signaler
to signal/interrupt the running function f
.
Implicit method that provides Timed
implementation for FutureOutcome
.
Implicit method that provides Timed
implementation for FutureOutcome
.
If the asynchronous function completes before the timeout expires:
-
If the function returns normally, the
FutureOutcome
will be completed with theOutcome
returned from the function. -
If the function completes abruptly with an
TestPendingException
, this method will complete theFutureOutcome
withPending
. -
If the function completes abruptly with an
TestCanceledException
, this method will complete theFutureOutcome
withCanceled
that contains the thrown exception. -
If the function completes abruptly with a run-aborting exception, this method will complete the
FutureOutcome
withFailed
that contains the thrown exception. -
If the function completes abruptly with a non-run-aborting exception, this method will fail the
FutureOutcome
withExecutionException
that contains the thrown exception.
If the asynchronous function completes after the timeout expires:
-
If the function returns normally, this method will complete the
FutureOutcome
with aOutcome
that's mapped from the exception thrown fromexceptionFun
. -
If the function completes abruptly with an exception, this method will complete the
FutureOutcome
withOutcome
that's mapped from the exception thrown fromexceptionFun
that includes the exception thrown by the function as its cause.
This implementation will start a timer that when the time limit is exceeded while the passed in asynchronous function f
is still running, it will attempt to call the passed in Signaler
to signal/interrupt the running function f
.