tree: 5ec08701172b3d668827516250b977a277280ffa [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.md
kotlinx-coroutines-core/README.md

Module kotlinx-coroutines-core

Core primitives to work with coroutines.

This module provides the following coroutine builders:

NameResultScopeDescription
launchJobCoroutineScopeLaunches coroutine that does not have any result
asyncDeferredCoroutineScopeReturns a single value with the future result
produceProducerJobProducerScopeProduces a stream of elements
runBlockingTCoroutineScopeBlocks the thread while the coroutine runs

These builders can be used with the following coroutine dispatchers:

NameDescription
CommonPoolConfines coroutine execution to a shared pool of threads
newSingleThreadContextCreate new single-threaded coroutine context
newFixedThreadPoolContextCreates new thread pool of a fixed size
Executor.toCoroutineDispatcherExtension to convert any executor
UnconfinedDoes not confine coroutine execution in any way

The following top-level suspending functions are provided to be used inside coroutines:

NameDescription
delayNon-blocking sleep
yieldYields thread in single-threaded dispatchers
runSwitches to a different context
withTimeoutSet execution time-limit (deadline)

Cancellation support for user-defined suspending functions is available with suspendCancellableCoroutine helper function. NonCancellable job object is provided to suppress cancellation with run(NonCancellable) {...} block of code.

This module provides debugging facilities for coroutines (run JVM with -ea or -Dkotlinx.coroutines.debug options) and newCoroutineContext function to write user-defined coroutine builders that work with these debugging facilities.

Package kotlinx.coroutines.experimental

General-purpose coroutine builders, contexts, and helper functions.

Package kotlinx.coroutines.experimental.channels

Channels -- non-blocking primitives for communicating a stream of elements between coroutines.