CommonPool
object CommonPool : CoroutineDispatcher
(source)Platform and version requirements: JVM
Represents common pool of shared threads as coroutine dispatcher for compute-intensive tasks.
If there isn’t a SecurityManager present it uses java.util.concurrent.ForkJoinPool when available, which implements
efficient work-stealing algorithm for its queues, so every coroutine resumption is dispatched as a separate task even
when it already executes inside the pool. When available, it wraps ForkJoinPool.commonPool
and provides a similar
shared pool where not.
If there is a SecurityManager present (as would be if running inside a Java Web Start context) then a plain thread pool is created. This is to work around the fact that ForkJoinPool creates threads that cannot perform privileged actions.
Functions
fun dispatch( Dispatches execution of a runnable block onto another thread in the given context. |
|
fun toString(): String |
Inherited Functions
open fun <T> interceptContinuation( Returns continuation that wraps the original continuation, thus intercepting all resumptions. |
|
open fun isDispatchNeeded(context: CoroutineContext): Boolean Returns |
Extension Functions
fun CoroutineContext.cancel( Cancels Job of this context with an optional cancellation cause. The result is |
|
fun CoroutineContext.cancelChildren( Cancels all children of the Job in this context with an optional cancellation cause. It does not do anything if there is no job in the context or it has no children. See Job.cancelChildren for details. |