Library support for Kotlin coroutines
TestScope.backgroundScope
for launching coroutines that perform work in the background and need to be cancelled at the end of the test (#3287).kotlinx-coroutines-debug
having an incorrect reference to kotlinx-coroutines-bom
, which cause the builds of Maven projects using the debug module to break (#3334).Publisher.await
functions in kotlinx-coroutines-reactive
not ensuring that the Subscriber
methods are invoked serially (#3360). Thank you, @EgorKulbachka!withTimeout
on K/N with the new memory model (#3351).Throwable
implementations in the core library are serializable (#3328).ThreadLocalElement
not being correctly updated when the most outer suspend
function was called directly without kotlinx.coroutines
(#2930).runBlocking
event loop, and a benign data race in Mutex
(#3250, #3251).TestCoroutineContext
is removed, which fixes the kotlinx-coroutines-test
JPMS package being split between kotlinx-coroutines-core
and kotlinx-coroutines-test
(#3218).0.17.2
, which includes a more efficient and robust JS IR transformer (#3255).1.6.21
, Gradle version is updated to 7.4.2
(#3281). Thanks, @wojtek-kalicinski!Dispatchers.Main
.
This behavior was introduced in 1.6.0 and then found inconvenient and erroneous (#3106, #3113).CopyableThreadContextElement
to solve issues uncovered after the initial release (#3227).ThreadLocalElement
not being properly updated in racy scenarios (#2930).CoroutineExceptionHandler
that triggered ANR on some devices (#3180).CoroutineDispatcher
to a Rx scheduler (#968, #548). Thanks @recheej!flow
builder being retained in memory (#3197).limitedParallelism
on K/N with new memory model throwing ClassCastException
(#3223).CoroutineContext
is added to the exception printed to the default CoroutineExceptionHandler
to improve debuggability (#3153).Dispatchers.Default
was significantly reduced (#3137).kotlinx-coroutines-slf4j
from 1.7.25 to 1.7.32.Note that this is a full changelog relative to the 1.5.2 version. Changelog relative to 1.6.0-RC3 can be found at the end.
kotlinx-coroutines-test
became a multiplatform library usable from K/JVM, K/JS, and K/N.CoroutineDispatcher.limitedParallelism
that allows obtaining a view of the original dispatcher with limited parallelism (#2919).Dispatchers.IO.limitedParallelism
usages ignore the bound on the parallelism level of Dispatchers.IO
itself to avoid starvation (#2943).Dispatchers.shutdown
method for containerized environments (#2558).newSingleThreadContext
and newFixedThreadPoolContext
are promoted to delicate API (#2919).future
builder no longer reports unhandled exceptions into the global CoroutineExceptionHandler
. Thanks @vadimsemenov! (#2774, #2791).Mutex.onLock
is deprecated for removal (#2794).Dispatchers.Main
is now used as the default source of time for delay
and withTimeout
when present (#2972).
kotlinx.coroutines.main.delay
system property can be set to false
.collect
no longer resolves when used with a non-in-place argument of a functional type. This is a candidate for a fix, uncovered after 1.6.0, see #3107 for the additional details.kotlin.native.binary.memoryModel
is enabled (#2914).CopyableThreadContextElement
for mutable context elements shared among multiple coroutines. Thanks @yorickhenning! (#2893).transformWhile
, awaitClose
, ProducerScope
, merge
, runningFold
, runingReduce
, and scan
are promoted to stable API (#2971).SharedFlow.subscriptionCount
no longer conflates incoming updates and gives all subscribers a chance to observe a short-lived subscription (#2488, #2863, #2871).Flow
exception transparency mechanism is improved to be more exception-friendly (#3017, #2860).flat*
operators that leverage multiple coroutines is no longer propagated upstream (#2964).SharedFlow.collect
now returns Nothing
(#2789, #2502).DisposableHandle
is now fun interface
, and corresponding inline extension is removed (#2790).FlowCollector
is now fun interface
, and corresponding inline extension is removed (#3047).processUnhandledException
(#2981).Task
callbacks in kotlinx-coroutines-play-services
(#2990).CoroutineExceptionHandler
is loaded eagerly and does not invoke ServiceLoader
on its exception-handling path (#2552).ServiceLoader
optimization (#2880).SendChannel.trySendBlocking
is now available on Kotlin/Native (#3064).ClassValue
when available (#2997).Delay
interface is deprecated (#2979).CommonPool
is removed.@ExperimentalTime
is no longer needed for methods that use Duration
(#3041).Flow.collect
couldn't be called due to the @InternalCoroutinesApi
annotation (#3082)TestCoroutineScheduler
now provides a TimeSource
with its virtual time via the timeSource
property. Thanks @hfhbd! (#3087)@ExperimentalTime
is no longer needed for methods that use Duration
(#3041).FlowCollector
is now fun interface
, and corresponding inline extension is removed (#3047).TestCoroutineScope
is no longer sealed, to simplify migration from it (#3072).runTest
gives more informative errors when it times out waiting for external completion (#3071).SendChannel.trySendBlocking
is now available on Kotlin/Native (#3064).Dispatchers.Main
was not used for delay
and withTimeout
(#3046).kotlinx-coroutines-test
became a multiplatform library usable from K/JVM, K/JS, and K/N.CoroutineDispatcher.limitedParallelism
that allows obtaining a view of the original dispatcher with limited parallelism (#2919).Dispatchers.IO.limitedParallelism
usages ignore the bound on the parallelism level of Dispatchers.IO
itself to avoid starvation (#2943).Dispatchers.shutdown
method for containerized environments (#2558).newSingleThreadContext
and newFixedThreadPoolContext
are promoted to delicate API (#2919).future
builder no longer reports unhandled exceptions into the global CoroutineExceptionHandler
. Thanks @vadimsemenov! (#2774, #2791).Mutex.onLock
is deprecated for removal (#2794).Dispatchers.Main
is now used as the default source of time for delay
and withTimeout
when present(#2972).
kotlinx.coroutines.main.delay
system property can be set to false
.kotlin.native.binary.memoryModel
is enabled (#2914).CopyableThreadContextElement
for mutable context elements shared among multiple coroutines. Thanks @yorickhenning! (#2839 ).transformWhile
, awaitClose
, ProducerScope
, merge
, runningFold
, runingReduce
, and scan
are promoted to stable API (#2971).SharedFlow.subscriptionCount
no longer conflates incoming updates and gives all subscribers a chance to observe a short-lived subscription (#2488, #2863, #2871).Flow
exception transparency mechanism is improved to be more exception-friendly (#3017, #2860).flat*
operators that leverage multiple coroutines is no longer propagated upstream (#2964).SharedFlow.collect
now returns Nothing
(#2789, #2502).FlowCollector
is now fun interface
, and corresponding inline extension is removed (#2790).processUnhandledException
(#2981).Task
callbacks in kotlinx-coroutines-play-services
(#2990).CoroutineExceptionHandler
is loaded eagerly and does not invoke ServiceLoader
on its exception-handling path (#2552).ServiceLoader
optimization (#2880).ClassValue
when available (#2997).Delay
interface is deprecated (#2979).CommonPool
is removed.onUndeliveredElement
was incorrectly called on properly received elements on JS (#2826).Dispatchers.Default
on React Native, it now fully relies on setTimeout
instead of stub process.nextTick
. Thanks to @Legion2 (#2843).Mutex
implementation (#2581).Mutex
implementation is made completely lock-free as stated (#2590).update
, getAndUpdate
, and updateAndGet
operations of MutableStateFlow
(#2720).Executor.asCoroutineDispatcher
implementation improvements (#2601):
ScheduledExecutorService
, then its schedule
API is used for time-related coroutine operations.RemoveOnCancelPolicy
is now part of the public contract.Task.asDeferred
and Task.await
that accept CancellationTokenSource
for bidirectional cancellation (#2527).1.0.3
(#2740).CopyableThrowable
is allowed to modify the exception message during stacktrace recovery (#1931).CoroutineDispatcher.releaseInterceptedContinuation
is now a final
method (#2785).Handler.asCoroutineDispatcher
now causes the dispatched coroutines to be canceled on Dispatchers.IO (#2778)
.ClassCastException
in releaseInterceptedContinuation
and IllegalStateException
from tryReleaseClaimedContinuation
(#2736, #2768).CompletableFuture.asDeferred
when the target future has a long chain of listeners (#2730).CoroutineDispatcher.isDispatchNeeded
are now considered as fatal and are propagated to the caller (#2733).DebugProbesKt
(used in the debugger implementation) are moved from debug
to core
module.