tuweni / org.apache.tuweni.concurrent.coroutines / kotlinx.coroutines.CoroutineScope

Extensions for kotlinx.coroutines.CoroutineScope

asyncCompletion

Starts new co-routine and returns its result as an implementation of AsyncCompletion. The running co-routine is cancelled when the resulting future is cancelled or otherwise completed.

fun CoroutineScope.asyncCompletion(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): AsyncCompletion

asyncResult

Starts new co-routine and returns its result as an implementation of AsyncResult. The running co-outine is cancelled when the resulting future is cancelled or otherwise completed.

fun <T> CoroutineScope.asyncResult(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): AsyncResult<T>

retry

Retry a suspending block until a non-null result is obtained.

suspend fun <R> CoroutineScope.retry(retryDelay: Long, block: suspend (Int) -> R?): R
suspend fun <R> CoroutineScope.retry(retryDelay: Long, maxRetries: Int, block: suspend (Int) -> R?): R?
suspend fun <R> CoroutineScope.retry(retryDelay: (Int) -> Long?, block: suspend (Int) -> R?): R?