withContextReentrant

suspend fun <T> withContextReentrant(context: ERROR CLASS: Symbol not found for CoroutineContext, block: suspend () -> T): T(source)

Runs the given block within the specified context in a reentrant-safe way.

The block normally runs with context, but if the current execution is already associated with the same continuation interceptor (dispatcher), it strips the interceptor from the context to avoid redispatching. This avoids redispatch deadlocks when all threads in the target context are busy.

Parameters

context

The target coroutine context in which the block should execute.

block

The suspend function to be executed within the specified context.