CancellableContinuation
in the final state produce IllegalStateException
(#901). This change does not affect #830, races between resume and cancellation do not lead to an exceptional situation.runBlocking
is integrated with Dispatchers.Unconfined
by sharing an internal event loop. This change does not affect the semantics of the previously correct code but allows to mix multiple runBlocking
and unconfined tasks (#860).kotlinx-coroutines-debug
. Debug agent that improves coroutines stacktraces, allows to print all active coroutines and its hierarchies and can be installed as Java agent.kotlinx-coroutines-test
. Allows setting arbitrary Dispatchers.Main
implementation for tests (#810).kotlinx.coroutines.debug
system property (#493).MainScope
factory and CoroutineScope.cancel
extension (#829). One line CoroutineScope
integration!CancellableContinuation
race between resumeWithException
and cancel
is addressed, exceptions during cancellation are no longer reported to exception handler (#830, #892).Dispatchers.Default
now consumes much less CPU on JVM (#840).DisposableHandle
(#835).JavaFx
initialization bug (#816).TimeoutCancellationException
is thrown by withTimeout
instead of CancellationException
if negative timeout is supplied (#870).Dispatchers.Default
on JS.kotlinx-coroutines-guava
.publisher
implementation with Reactive TCK.future
coroutine builders on top of AbstractCoroutine
(#751).Dispatchers.Default
and Dispatchers.IO
.JavaFx
instantiation, fixes warnings on Java 9 and build on Java 11 (#463).CancellableContinuation.resumeWithException
(documentation fix, see #712).withContext
, coroutineScope
, supervisorScope
, withTimeout
and withTimeoutOrNull
).ExperimentalCoroutineDispatcher
(#661).ExperimentalCoroutineDispatcher
could end up in inconsistent state if Thread
constructor throws an exception (#748).HandlerDispatcher.scheduleResumeAfterDelay
, thanks @cbeyls.yield
support for Unconfined
and immediate dispatchers (#737).internal
.kotlin.experimental.Experimental
annotation. If you are using @ExperimentalCoroutinesApi
or @InternalCoroutinesApi
you should explicitly opt-in, otherwise compilation warning (or error) will be produced.Unconfined
dispatcher (and all dispatchers which support immediate invocation) forms event-loop on top of current thread, thus preventing all StackOverflowError
s. Unconfined
dispatcher is now much safer for the general use and may leave its experimental status soon (#704).kotlinx.coroutines
(#537).runBlocking
(#692).ReceiveChannel.receiveOrNull
is marked as obsolete and deprecated.Job.cancel(cause)
and ReceiveChannel.cancel(cause)
are deprecated, cancel()
returns Unit
(#713).Dispatchers.Main
is instantiated lazily (see #658 and #665).withContext
cancellation (#675).Maintenance release:
Dispatchers.Main
to common dispatchers, which can be used from Android, Swing and JavaFx projects if a corresponding integration library is added to dependencies.Dispatchers.Main
improvement tooling bug in Android Studio #626 is mitigated, so Android users now can safely start the migration to the latest kotlinx.coroutines
version.EventLoop
.close
contract similar to Java Executor
, so it can be safely instantiated and closed multiple times (affects only unit tests).async
and async-like builders cancel parent on failure (it affects CompletableDeferred
, and all reactive integration builders).awaitAll
(see #552).Job()
wih parent now also cancels parent on failure consistently with other scopes.Job
implementations propagate failure to the parent unless it is a CancellationException
.SupervisorJob()
and supervisorScope { ... }
are introduced, allowing for a flexible implementation of custom exception-handling policies, see a new section in the guide on supervision.awaitAll
in documentation and rewrote currentScope
section (see #624).Dispatchers.Default
by default instead of deprecated CommonPool
.DefaultDispatcher
" is used as a public name of the default impl (you'll see it thread names and in the guide).-Dkotlinx.coroutines.scheduler=off
can be used to switch back to CommonPool
for a time being (until deprecated CommonPool is removed).CoroutineStart.ATOMIC
experimental as it covers important use-case with resource cleanup in finally block (see #627).Executor.asCoroutineDispatcher
(see #629).Dispatchers.Unconfined
(see #621).1.0
release:@Deprecated
API. All API marked as deprecated will be removed in 1.0 release without replacement.@ExperimentalCoroutinesApi
API. This API is experimental and may change in the future, but migration mechanisms will be provided. Signature, binary compatibility and semantics can be changed.@InternalCoroutinesApi
. This API is intended to be used only from within kotlinx.coroutines
. It can and will be changed, broken and removed in the future releases without any warnings and migration aids. If you find yourself using this API, it is better to report your use-case to Github issues, so decent, stable and well-tested alternative can be provided.@ObsoleteCoroutinesApi
. This API has serious known flaws and will be replaced with a better alternative in the nearest releases.CancellationException
, transparent parallel decomposition and consistent view of coroutines hierarchy in terms of its state (see #220 and #585).withContext
is now aligned with structured concurrency and awaits for all launched tasks, its performance is significantly improved (see #553 and #617).CompletableFuture.await
and ListenableFuture.await
now propagate cancellation to the future (see #611).runBlocking
machinery is improved (see #589).CoroutineScope
factory methods add Job
if it is missing from the context to enforce structured concurrency (see #610).Handler.asCoroutineDispatcher
has a name
parameter for better debugging (see #615).CoroutineSchedule
was closed from one of its threads (see #612).CoroutineExceptionHandler
are reported by default exception handler (see #562).CoroutineName
is now available from common modules (see #570).Main
dispatcher is async
by default which may significantly improve UI performance. Contributed by @JakeWharton (see #427).CoroutineScope.plus
operator (see #559).kotlinx.coroutines
concurrency model (see #410 for a full explanation of the rationale behind this change):CoroutineScope
and inherit its coroutineContext
. Standalone builders are deprecated.CoroutineDispatcher
.Dispatchers.Default
by default if CoroutineInterceptor
is not present in their context.kolinx.coroutines
.withContext
block
argument has CoroutineScope
as a receiver.currentScope
and coroutineScope
builders are introduced to extract and provide CoroutineScope
.CoroutineScope
from CoroutineContext
are introduced.CoroutineScope.isActive
became an extension property.CommonPool
are deprecated.invokeOnCompletion(onCancelling = true)
.Thread.contextClassLoader
is mocked (see #530).IO
dispatcher silently hung (see #524 and #525) .Job.cancel
resulting Boolean
value changed — true
means exception was handled by the job, caller shall handle otherwise.CoroutineExceptionHandler
for a family of coroutines receives one aggregated exception in case of failure.handleCoroutineException
contract, so custom exception handlers can't break coroutines machinery.JobCancellationException
properly to provide exception transparency over whole call chain.ThreadContextElement
API for custom thread-context sensitive context elements.ThreadLocal.asContextElement()
extension function to convert an arbitrary thread-local into coroutine context element.MDCContext
element defined in kotlinx-coroutines-slf4j
integration module.ExecutorCoroutineDispatcher
instead of CloseableCoroutineDispatcher
(see #385).kotlinx-coroutines
are now JEP 238 multi-release JAR files.VarHandle
is used for atomic operations instead of Atomic*FieldUpdater
for better performance.BlockingChecker
extension point to control where runBlocking
can be used (see #227).runBlocking
can be used anywhere without limitations (again), but it would still cause problems if improperly used on UI thread.EventLoop
pseudo-constructor (see #477, PR by @Groostav).as*Future()
integration functions to catch all Throwable
exceptions (see #469).runBlocking
cancellation (see #501).withTimeoutOrNull
(see #498).EventLoop.invokeOnTimeout
in DefaultDispatcher
to allow busy-wait loops inside runBlocking
(see #479).kotlinx-coroutines-io
module from the project, it has moved to kotlinx-io.runBlocking
event loop is supported at this moment.SendChannel.invokeOnClose
(see #341).close
, cancel
, isClosedForSend
, isClosedForReceive
and offer
linearizable with other operations (see #359).BlockingChecker
mechanism which checks current context (see #227).runBlocking
from any supported UI thread (Android, JavaFx, Swing) will result in exception.UI.immediate
extension as performance-optimization to immediately execute tasks which are invoked from the UI thread (see #381).cause
exception for Job
onCancelling handlers (see #436).UI
on Java 9 (see #443).-Dkotlinx.coroutines.scheduler
option. In this case DefaultDispatcher
is set to new experimental scheduler instead of FJP-based CommonPool
.openChannel().use { ... }
pattern by providing deprecated extension function use
on ReceiveChannel
.broadcast
coroutine builder (see #280):BroadcastChannel.cancel
method to drop the buffer.ReceiveChannel.broadcast()
extension.CancellableContinuation
is not a Job
anymore (see #219):suspendCancellableCoroutine
, since all the typically used functions are still there.CancellableContinuation.invokeOnCompletion
is deprecated now and its semantics had subtly changed:invokeOnCancellation
is a replacement for invokeOnCompletion
to install a handler.resume
which corresponds to the typical usage pattern.cont.isCancelled
in a typical handler code anymore (since handler is invoked only when continuation is cancelled).CancellableContinuation
implementation has simpler state machine and is implemented more efficiently.AbstractContinuation
(that implements CancellableContinuation
) is now consistent:CoroutineScope.coroutineContext
:coroutineContext
function from Kotlin standard library.ReceiveChannel
operators implementations to guarantee closing of the source channels under all circumstances (see #279):onCompletion
parameter added to produce
and all other coroutine builders.ReceiveChannel.consumes(): CompletionHandler
extension function.SubscriptionReceiveChannel
with ReceiveChannel
(see #283, PR by @deva666).ReceiveChannel.use
extension is introduced to preserve source compatibility, but is deprecated.consume
or consumeEach
extensions should be used for channels.produce(onCompletion=consumes()) { ... }
pattern shall be used (see #279 above).awaitAll
and joinAll
for Deferred
and Job
lists correspondingly (see #171).CompletionException
exception in CompletionStage.await
slow-path to provide consistent results (see #375).ExecutorService
to return CloseableCoroutineDispatcher
(see #278, PR by @deva666).delay
, withTimeout
and onTimeout
(see #310).delay
:clearTimeout
on cancellation in JSDispatcher.ticker
function to create "ticker channels" (see #327):Observable.timer
for coroutine channels.TestCoroutineContext
(see #297, PR by @streetsofboston).CoroutineContext.DEBUG
value (see #316, PR by @dmytrodanylyk):CoroutineContext.DEBUG_PROPERTY_NAME
constant public."on"
, "off"
, "auto"
values.CommonPool
parallelism (see #343):CommonPool.DEFAULT_PARALLELISM_PROPERTY_NAME
constant is introduced with a value of "kotlinx.coroutines.default.parallelism".Channel.filterNot
(PR by @jcornaz).toString
for channels (see #185).CompletionStage
to Deferred
(see #262, PR by @jcornaz).CompletionStage.await
and make it cancellable.produce
builder to close the channel on completion instead of cancelling it, which lead to lost elements with buffered channels (see #256).ForkJoinPool
if there is a SecurityManager
present to work around JNLP problems (see #216, PR by @NikolayMetchev).window.addEventListener
when choosing default coroutine dispatcher (see #230, PR by @ScottPierce).1.3.6
.2.1.9
.24.0-jre
.awaitFirstOrDefault
and awaitFirstOrNull
extensions (see #224, PR by @konrad-kaminski).withTimeout
and withTimeoutOrNull
that should not use equals on result (see #212, PR by @konrad-kaminski).actor
builder documentation (see #210) and fixed bugs in rendered documentation due to multiplatform.runBlocking
to properly support specified dispatchers (see #209).Job
implementation (it was hanging at LockFreeLinkedList.helpDelete
on certain stress tests).AbstractCoroutine.onCancellation
is invoked before cancellation handler that is set via invokeOnCompletion
.launch
handles uncaught exception before another coroutine that uses join
on it resumes (see #208).AbstractCoroutine
:Job
, Continuation
, and CoroutineScope
.onStart
, onCancellation
, onCompleted
and onCompletedExceptionally
functions.launch
handles uncaught exceptions before "joining" coroutines wakeup (see #208).openSubscription
extension for reactive Publisher
/Observable
/Flowable
when used with select { ... }
and added an optional request
parameter to specify how many elements are requested from publisher in advance on subscription (see #197).Channel.flatMap
using toChannel
function to work around Android 5.0 APK install SIGSEGV (see #205).DispatchTask
instance is no longer allocated).Job.cancel
and CompletableDeferred.complete
to support cancelling/completing states and properly wait for their children to complete on join/await (see #199).delay
) which could have resulted in wrong delay time in rare circumstances.Promise.asDeferred
immediately installs handlers to avoid "Unhandled promise rejection" warning.window.postMessage
instead of setTimeout
for coroutines inside the browser to avoid timeout throttling (see #194).Window.awaitAnimationFrame
to align all animations and reduce overhead.Window.asCoroutineDispatcher()
extension function.launch
and async
coroutine builders.Job
and Deferred
light-weight future with cancellation support.delay
and yield
top-level suspending functions.await
extension for JS Promise
and asPromise
/asDeferred
conversions.promise
coroutine builder.Job()
and CompletableDeferred()
factories.Window.awaitAnimationFrame
extension function.run
is deprecated and renamed to withContext
(see #134).runBlocking
and EventLoop
implementations optimized (see #190).filter
, map
, etc extensions on ReceiveChannel
are introduced (see #88 by @fvasco and #69 by @konrad-kaminski).ReceiveChannel.cancel
method.ReceiveChannel
fully consume the original channel (cancel
it when they are done) using a helper consume
extension.ActorJob
and ProducerJob
; actor
now returns SendChannel
and produce
returns ReceiveChannel
(see #127).SendChannel.sendBlocking
extension method (see #157 by @@fvasco).parent
job parameter for all coroutine builders so that code with an explict parent Job
is more natural.parent
parameter to CompletableDeferred
constructor.Job.children
property.Job.cancelChildren
is now an extension (member is deprecated and hidden).Job.joinChildren
extension is introduced.Job.attachChild
as a error-prone API.java.util.ServiceLoader
to find default instances of CoroutineExceptionHandler
.Thread.getUncaughtExceptionPreHandler
to make sure that exceptions are logged before crash (see #148).UI.awaitFrame
for animation; added sample coroutine-based animation application for Android here.delay(Long.MAX_VALUE)
(see #161)DefaultDispatcher
on some reactive operators (see #174 by @fvasco)actor
and produce
so that a cancellation of a Job cancels the underlying channel (closes and removes all the pending messages).example-context-06
(see #160)Job.start
on lazy coroutine with attached invokeOnCompletion
handler.runBlocking
and coroutines in the guide (see #166).send
/openSubscription
race in ArrayBroadcastChannel
. This race lead to stalled (hanged) send
/receive
invocations.ArrayBroadcastChannel
receive of stale elements on openSubscription
. Only elements that are sent after invocation of openSubscription
are received now.context
parameter to rxFlowable
(see #146 by @PhilGlass).UnexpectedCoroutineException
is no longer used to report those cases as is removed.run
uses cancelling state & propagates exceptions when cancelled (see #147):run
is cancelled, the run invocation does not complete immediately, but waits until the body completes.Job
in newSingleThreadContext
and newFixedThreadPoolContext
anymore (see #149, #151):run(ctx)
where ctx comes from either newSingleThreadContext
or newFixedThreadPoolContext
invocation. They both used to return a combination of dispatcher + job, and this job was overriding the parent job, thus preventing propagation of cancellation. Not anymore.ThreadPoolDispatcher
class is now public and is the result type for both functions. It has the close
method to release the thread pool.try/catch
or other exception handlers.ArrayBroadcastChannel
between send
and openChannel
invocations (see #138).runBlocking
that resulted in AssertionError
. Unfortunately, cannot write a reliable stress-test to reproduce it.DefaultDispatcher
is introduced (see #136):launch
, async
, produce
, actor
and other integration-specific coroutine builders now use DefaultDispatcher
as the default value for their context
parameter.newCoroutineContext
function checks if there is any interceptor/dispatcher defined in the context and uses DefaultDispatcher
if there is none.DefaultDispatcher
is currently defined to be equal to CommonPool
.launch { ... }
code and explanation on the nature and the need for coroutine context starts in "Coroutine context and dispatchers" section.Job.attachChild
and Job.cancelChildren
are introduced.Job.join
now always checks cancellation status of invoker coroutine for predictable behavior when joining failed child coroutine.Job.cancelAndJoin
extension is introduced.CoroutineContext.cancel
and CoroutineContext.cancelChildren
extensions are introduced for convenience.withTimeout
/withTimeoutOrNull
blocks become proper coroutines that have CoroutineScope
and wait for children, too.CancellationException
(as was documented before) even when the coroutine is cancelled with another application-specific exception.JobCancellationException
is introduced as a specific subclass of CancellationException
which is used for coroutines that are cancelled without cause and to wrap application-specific exceptions.Job.getCompletionException
is renamed to Job.getCancellationException
and return a wrapper exception if needed.Deferred.getCompletionExceptionOrNull
to get not-wrapped exception result of async
task.Job
& Deferred
to explain parent/child relations.select
expression is modularized:SelectClause(0,1,2)
interfaces are introduced, so that synchronization constructs can define their select clauses without having to modify the source of the SelectBuilder
in kotlinx-corounes-core
module.Job.onJoin
, Deferred.onAwait
, Mutex.onLock
, SendChannel.onSend
, ReceiveChannel.onReceive
, etc that were functions before are now properties returning the corresponding select clauses. Old functions are left in bytecode for backwards compatibility on use-site, but any outside code that was implementing those interfaces by itself must be updated.TimeoutException
to TimeoutCancellationException
(old name is deprecated).JavaFx
context (see #108).delay
in arbitrary contexts (see #133).kotlinx-coroutines-io
module is introduced. It is a work-in-progress on ByteReadChannel
and ByteWriteChannel
interfaces, their implementations, and related classes to enable convenient coroutine integration with various asynchronous I/O libraries and sockets. It is currently unstable and will change in the next release.withLock
and consumeEach
functions are now inline suspend functions.JobSupport
class implementation is optimized (one fewer field).TimeoutException
is public (see #89).Mutex
(courtesy of @fvasco):holdsLock
(see #92).Mutex
fairness (see #90).ArrayBroadcastChannel
is closed concurrently with receive (see #97).setCancellation
with onDipose
and updated to Aluminium-SR3 release (courtesy of @yxf07, see #96)java.time
classes (courtesy of @fvasco, see #93)CompletableDeferred
is introduced as a set-once event-like communication primitive (see #70).CompletableDeferred
is an interface with private impl (courtesy of @fvasco, see #86).Deferred
interface with complete
and completeExceptionally
functions.Job.join
and Deferred.await
wait until a cancelled coroutine stops execution (see #64).Job
and Deferred
have a new cancelling state which they enter on invocation of cancel
.Job.invokeOnCompletion
has an additional overload with onCancelling: Boolean
parameter to install handlers that are fired as soon as coroutine enters cancelling state as opposed to waiting until it completes.select
implementation is refactored to decouple it from JobSupport
internal class and to optimize its state-machine.AbstractCoroutine
class is refactored so that it is extended only by true coroutines, all of which support the new cancelling state.CoroutineScope.context
is renamed to coroutineContext
to avoid conflicts with other usages of context
in applications (like Android context, see #75).BroadcastChannel.open
is renamed to openSubscription
(see #54).StackOverflowError
in a convoy of Mutex.unlock
invokers with Unconfined
dispatcher (see #80).SecurityException
when trying to use coroutines library with installed SecurityManager
.withTimeoutOrNull
in case with nested timeouts when coroutine was cancelled before it was ever suspended.awaitFirst
on reactive streams that would have resulted in spurious stack-traces printed on the console when used with publishers/observables that continue to invoke onNext
despite being cancelled/disposed (which they are technically allowed to do by specification).Job
, Channel
, BroadcastChannel
, Mutex
, EventLoop
, and CoroutineExceptionHandler
). Previous approach of using operator invoke
on their companion objects is deprecated.toString
implementations for coroutine dispatcher tasks and continuations.delay
is rewritten and now shares code with EventLoopImpl
that is used by runBlocking
. It internally supports non-default TimeSource
so that delay-using tests can be written with "virtual time" by replacing their time source for the duration of tests (this feature is not available outside of the library).suspendAtomicCancellableCoroutine
function is introduced for funs like send
/receive
/receiveOrNull
that require atomic cancellation (they cannot be cancelled after decision was made)async
/launch
/actor
builders can be cancelled before their execution startsCoroutineStart.ATOMIC
is introduced as a start mode to specify that coroutine cannot be cancelled before its execution startsrun
function is also cancellable in the same way and accepts an optional CoroutineStart
parameter to change this default.BroadcastChannel
factory function is introducedCoroutineExceptionHandler
factory function is introduced by @konrad-kaminskiintegration
directory is introduced for all 3rd party integration projectsListenableFuture
in the new kotlinx-coroutines-guava
moduleChannel
and BroadcastChannel
implementation bugs related to concurrent send/close/close of channels that lead to hanging send, offer or close operations (see #66). Thanks to @chrisly42 and @cy6erGn0m for finding them.withTimeoutOrNull
which was returning null
on timeout of inner or outer withTimeout
blocks (see #67). Thanks to @gregschlom for finding the problem.Job
fails to dispose a handler when it is the only handler by @uchuhimoCoroutineStart
enum is introduced for launch
/async
/actor
builders:luanch(context, start = false)
is deprecated and is replaced with launch(context, CoroutineStart.LAZY)
CoroutineStart.UNDISPATCHED
is introduced to start coroutine execution immediately in the invoker thread, so that async(context, CoroutineStart.UNDISPATCHED)
is similar to the behavior of C# async
.BroadcastChannel
interface in kotlinx-coroutines-core
module:SendChannel
interface and provides open
function to create subscriptions.SubscriptionReceiveChannel
interface.SubscriptionReceiveChannel
interfaces are removed from reactive implementation modules. They use an interface defined in kotlinx-coroutines-core
module.ConflatedBroadcastChannel
implementation is provided for state-observation-like use-cases, where a coroutine or a regular code (in UI, for example) updates the state that subscriber coroutines shall react to.ArrayBroadcastChannel
implementation is provided for event-bus-like use-cases, where a sequence of events shall be received by multiple subscribers without any omissions.Mono
and Flux
. See kotlinx-coroutines-reactor
module.Completable.awaitCompleted
.Maybe
.withTimeoutOrNull
function.onTimeout
clause for select
expressions.withTimeout
blocks on their cancellation.withTimeout
when CancellationException
is suppressed inside the block. Invocation of withTimeout
now always returns the result of execution of its inner block.channel
property in ActorScope
is promoted to a wider Channel
type, so that an actor can have an easy access to its own inbox send channel.Mutex.withMutex
to Mutex.withLock
, old name is deprecated.consumeEach
helper function for channels and reactive streams, Rx 1.x, and Rx 2.x.for
loop on reactive streams is deprecated.awaitFirstOrDefault
extension for reactive streams, Rx 1.x, and Rx 2.x.Mutex.withMutex
helper function.kotlinx-coroutines-android
module has provided
dependency on of Android APIs to eliminate warnings when using it in android project.kotlinx-coroutinex-android
module with Android UI
context implementation.whileSelect
convenience function.ConflatedChannel
.toXXX
conversion functions to asXXX
(old names are deprecated).run
is optimized with fast-path case and no longer has CoroutineScope
in its block.withTimeout
(removed extra dispatch).EventLoop
that is used by runBlocking
now implements Delay, giving more predictable test behavior.Job.Registration
is renamed to DisposableHandle
.EmptyRegistration
is renamed to NonDisposableHandle
.Job.unregisterOnCompletion
is renamed to Job.disposeOnCompletion
.Delay.invokeOnTimeout
is introduced.withTimeout
now uses Delay.invokeOnTimeout
when available.rxFlowable
builder for Rx 2.x.Scheduler.asCoroutineDispatcher
extension for Rx 2.x.onComplete
in publish
, rxObservable
, and rxFlowable
builders.Closeable
.CompletableSource.await
and added test for it.rx.Completable.await
due to name conflict.LinkedListChannel
with unlimited buffer (offer
always succeeds).onLock
select clause and an optional owner
parameter in all Mutex
functions.selectUnbiased
function.actor
coroutine builder.select
expression with onJoin/onAwait/onSend/onReceive clauses.Mutex
is moved to kotlinx.coroutines.sync
package.ClosedSendChannelException
is a subclass of CancellationException
now.Mutex
synchronization primitive is introduced.buildChannel
is renamed to produce
, old name is deprecated.Job.onCompletion
is renamed to Job.invokeOnCompletion
, old name is deprecated.delay
implementation in Swing, JavaFx, and scheduled executors is fixed to avoid an extra dispatch.CancellableContinuation.resumeUndispatched
is introduced to make this efficient implementation possible.CancellationException
to improve performance, plus other performance improvements.defer
coroutine builder is renamed to async
.lazyDefer
is deprecated, async
has an optional start
parameter instead.LazyDeferred
interface is deprecated, lazy start functionality is integrated into Job
interface.launch
has an optional start
parameter for lazily started coroutines.Job.start
and Job.isCompleted
are introduced.Deferred.isCompletedExceptionally
and Deferred.isCancelled
are introduced.Job.getInactiveCancellationException
is renamed to getCompletionException
.Job.join
is now a member function.JobSupport
state machine is enhanced to support new (not-started-yet) state. So, lazy coroutines do not need a separate state variable to track their started/not-started (new/active) status.Job.cancel
(original cause is rethrown).Job
/CancellableContinuation
/Deferred
in docs.Channel
, SendChannel
, and ReceiveChannel
interfaces, RendezvousChannel
and ArrayChannel
implementations, Channel()
factory function and buildChannel{}
coroutines builder.Here
context is renamed to Unconfined
(the old name is deprecated).currentCoroutineContext
and related thread-locals without replacement. Explicitly pass coroutine context around if needed.lazyDefer(context) {...}
coroutine builder and LazyDeferred
interface are introduced.CoroutineDispatcher.isDispatchNeeded
function has a default implementation that returns true
.NonCancellable
context is introduced.CoroutineDispatcher
methods now have context
parameter.CancellableContinuation.isCancelled
EventLoop
dispatcher and made it a default for runBlocking { ... }
CoroutineScope
interface with isActive
and context
properties; standard coroutine builders include it as receiver for convenience.Executor.toCoroutineDispatcher()
extension.newCoroutineContext
can be explicitly disabled with -Dkotlinx.coroutines.debug=off
.kotlinx-coroutines-nio
module