tree: fed4bbff49158415342501115f3e792519b9e2b1 [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.

Coroutine builder functions:

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

Coroutine dispatchers implementing CoroutineDispatcher:

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

Synchronization primitives for coroutines:

NameSuspending functionsDescription
MutexlockMutual exclusion
Channelsend, receiveCommunication channel (aka queue or exchanger)

Top-level suspending functions:

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.