public class TimeoutKt
| Modifier and Type | Method and Description |
|---|---|
static <T> java.lang.Object |
withTimeout(long timeMillis,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block,
kotlin.coroutines.experimental.Continuation<? super T> p)
Runs a given suspending block of code inside a coroutine with a specified timeout and throws
exception TimeoutCancellationException if timeout was exceeded. |
static <T> java.lang.Object |
withTimeoutOrNull(long timeMillis,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block,
kotlin.coroutines.experimental.Continuation<? super T> p)
Runs a given suspending block of code inside a coroutine with a specified timeout and returns
null if this timeout was exceeded. |
public static <T> java.lang.Object withTimeout(long timeMillis,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block,
kotlin.coroutines.experimental.Continuation<? super T> p)
Runs a given suspending block of code inside a coroutine with a specified timeout and throws
exception TimeoutCancellationException if timeout was exceeded.
The code that is executing inside the block is cancelled on timeout and the active or next invocation of
cancellable suspending function inside the block throws exception TimeoutCancellationException.
The sibling function that does not throw exception on timeout is withTimeoutOrNull.
Note, that timeout action can be specified for select invocation with SelectBuilder.onTimeout clause.
This function delegates to Delay.invokeOnTimeout if the context class CoroutineDispatcher
implements Delay interface, otherwise it tracks time using a built-in single-threaded scheduled executor service.
timeMillis - timeout time in milliseconds.exception TimeoutCancellationException,
exception TimeoutCancellationException,
SelectBuilder.onTimeout,
class CoroutineDispatcherpublic static <T> java.lang.Object withTimeoutOrNull(long timeMillis,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block,
kotlin.coroutines.experimental.Continuation<? super T> p)
Runs a given suspending block of code inside a coroutine with a specified timeout and returns
null if this timeout was exceeded.
The code that is executing inside the block is cancelled on timeout and the active or next invocation of
cancellable suspending function inside the block throws exception TimeoutCancellationException.
The sibling function that throws exception on timeout is withTimeout.
Note, that timeout action can be specified for select invocation with SelectBuilder.onTimeout clause.
This function delegates to Delay.invokeOnTimeout if the context class CoroutineDispatcher
implements Delay interface, otherwise it tracks time using a built-in single-threaded scheduled executor service.
timeMillis - timeout time in milliseconds.exception TimeoutCancellationException,
SelectBuilder.onTimeout,
class CoroutineDispatcher