64 KiB
Change log for kotlinx.coroutines
Version 1.3.1
This is a minor update with various fixes:
- Flow: Fix recursion in combineTransform<T1, T2, R> (#1466).
- Fixed race in the Semaphore (#1477).
- Repaired some of ListenableFuture.kt's cancellation corner cases (#1441).
- Consistently unwrap exception in slow path of CompletionStage.asDeferred (#1479).
- Various fixes in documentation (#1496, #1476, #1470, #1468).
- Various cleanups and additions in tests.
Note: Kotlin/Native artifacts are now published with Gradle metadata format version 1.0, so you will need Gradle version 5.3 or later to use this version of kotlinx.coroutines in your Kotlin/Native project.
Version 1.3.0
Flow
This version is the first stable release with Flow API.
All Flow API not marked with @FlowPreview or @ExperimentalCoroutinesApi annotations are stable and here to stay.
Flow declarations marked with @ExperimentalCoroutinesApi have the same guarantees as regular experimental API.
Please note that API marked with @FlowPreview have weak guarantees on source, binary and semantic compatibility.
Changelog
- A new guide section about Flow.
CoroutineDispatcher.asExecutorextension (#1450).- Fixed bug when
selectstatement could report the same exception twice (#1433). - Fixed context preservation in
flatMapMergein a case when collected values were immediately emitted to another flow (#1440). - Reactive Flow integrations enclosing files are renamed for better interoperability with Java.
- Default buffer size in all Flow operators is increased to 64.
- Kotlin updated to 1.3.50.
Version 1.3.0-RC2
Flow improvements
-
Operators for UI programming are reworked for the sake of consistency, naming scheme for operator overloads is introduced:
combineLatestis deprecated in the favor ofcombine.combineTransformoperator for non-trivial transformations (#1224).- Top-level
combineandcombineTransformoverloads for multiple flows (#1262). switchMapis deprecated.flatMapLatest,mapLatestandtransformLatestare introduced instead (#1335).collectLatestterminal operator (#1269).
-
Improved cancellation support in
flattenMerge(#1392). -
channelFlowcancellation does not leak to the parent (#1334). -
Fixed flow invariant enforcement for
suspend fun main(#1421). -
delayEachanddelayFloware deprecated (#1429).
General changes
-
Integration with Reactor context
- Propagation of the coroutine context of
awaitcalls into Mono/Flux builder. - Publisher.asFlow propagates coroutine context from
collectcall to the Publisher. - New
Flow.asFluxbuilder.
- Propagation of the coroutine context of
-
ServiceLoader-code is adjusted to avoid I/O on the Main thread on newer (3.6.0+) Android toolchain.
-
Stacktrace recovery support for minified builds on Android (#1416).
-
Guava version in
kotlinx-coroutines-guavaupdated to28.0. -
setTimeout-based JS dispatcher for platforms whereprocessis unavailable (#1404). -
Native, JS and common modules are added to
kotlinx-coroutines-bom. -
Fixed bug with ignored
acquiredPermitsinSemaphore(#1423).
Version 1.3.0-RC
Flow
- Core
FlowAPI is promoted to stable - New basic
Flowoperators:withIndex,collectIndexed,distinctUntilChangedoverload - New core
Flowoperators:onStartandonCompletion ReceiveChannel.consumeAsFlowandemitAll(#1340)
General changes
- Kotlin updated to 1.3.41
- Added
kotlinx-coroutines-bomwith Maven Bill of Materials (#1110) - Reactive integrations are seriously improved
- All builders now are top-level functions instead of extensions on
CoroutineScopeand prohibitJobinstance in their context to simplify lifecycle management - Fatal exceptions are handled consistently (#1297)
- Integration with Reactor Context added (#284)
- All builders now are top-level functions instead of extensions on
- Stacktrace recovery for
suspend fun main(#1328) CoroutineScope.cancelextension with message (#1338)- Protection against non-monotonic clocks in
delay(#1312) Duration.ZEROis handled properly in JDK 8 extensions (#1349)- Library code is adjusted to be more minification-friendly
Version 1.3.0-M2
- Kotlin updated to 1.3.40.
Flowexception transparency concept.- New declarative
Flowoperators:onCompletion,catch,retryWhen,launchIn.onError*operators are deprecated in favour ofcatch. (#1263) Publisher.asFlowis integrated withbufferoperator.Publisher.openSubscriptiondefault request size is1instead of0(#1267).
Version 1.3.0-M1
Flow:
- Core
Flowinterfaces and operators are graduated from preview status to experimental. - Context preservation invariant rework (#1210).
channelFlowandcallbackFlowreplacements forflowViaChannelfor concurrent flows or callback-based APIs.flowprohibits emissions from non-scoped coroutines by default and recommends to usechannelFlowinstead to avoid most of the concurrency-related bugs.
- Flow cannot be implemented directly
AbstractFlowis introduced for extension (e.g. for managing state) and ensures all context preservation invariants.
- Buffer size is decoupled from all operators that imply channel usage (#1233)
bufferoperator can be used to adjust buffer size of any buffer-dependent operator (e.g.channelFlow,flowOnandflatMapMerge).conflateoperator is introduced.
- Flow performance is significantly improved.
- New operators:
scan,scanReduce,first,emitAll. flowWithandflowViaChannelare deprecated.retryignores cancellation exceptions from upstream when the flow was externally cancelled (#1122).combineLatestoverloads for multiple flows (#1193).- Fixed numerical overflow in
dropoperator.
Channels:
consumeEachis promoted to experimental API (#1080).- Conflated channels always deliver the latest value after closing (#332, #1235).
- Non-suspending
ChannelIterator.nextto improve iteration performance (#1162). - Channel exception types are consistent with
produceand are no longer swallowed as cancellation exceptions in case of programmatic errors (#957, #1128). - All operators on channels (that were prone to coroutine leaks) are deprecated in the favor of
Flow.
General changes:
- Kotlin updated to 1.3.31
Semaphoreimplementation (#1088)- Loading of
Dispatchers.Mainis tweaked so the latest version of R8 can completely remove I/O when loading it (#1231). - Performace of all JS dispatchers is significantly improved (#820).
withContextchecks cancellation status on exit to make reasoning about sequential concurrent code easier (#1177).- Consistent exception handling mechanism for complex hierarchies (#689).
- Convenient overload for
CoroutinesTimeout.seconds(#1184). - Fix cancellation bug in onJoin (#1130).
- Prevent internal names clash that caused errors for ProGuard (#1159).
- POSIX's
nanosleepasdelayinrunBlockingin K/N (#1225).
Version 1.2.2
- Kotlin updated to 1.3.40.
Version 1.2.1
Major:
- Infrastructure for testing coroutine-specific code in
kotlinx-coroutines-test:runBlockingTest,TestCoroutineScopeandTestCoroutineDispatcher, contributed by Sean McQuillan (@objcode). ObsoleteTestCoroutineContextfromkotlinx-coroutines-coreis deprecated. Job.asCompletableFutureextension in jdk8 module (#1113).
Flow improvements:
flowViaChannelrework: block parameter is no longer suspending, but providesCoroutineScopereceiver and allows conflated channel (#1081, #1112).- New operators:
switchMap,sample,debounce(#1107). consumerEachis deprecated onPublisher,ObservableSourceandMaybeSource,collectextension is introduced instead (#1080).
Other:
- Race in Job.join and concurrent cancellation is fixed (#1123).
- Stacktrace recovery machinery improved: cycle detection works through recovered exceptions, cancellation exceptions are recovered on cancellation fast-path.
- Atomicfu-related bug fixes: publish transformed artifacts, do not propagate transitive atomicfu dependency (#1064, #1116).
- Publication to NPM fixed (#1118).
- Misplaced resources are removed from the final jar (#1131).
Version 1.2.0
- Kotlin updated to 1.3.30.
- New API:
CancellableContinuation.resumewithonCancellinglambda (#1044) to consistently handle closeable resources. - Play services task version updated to 16.0.1.
ReceiveChannel.isEmptyis no longer deprecated
A lot of Flow improvements:
- Purity property is renamed to context preservation and became more restrictive.
zipandcombineLatestoperators.- Integration with RxJava2
flatMap,mergeandconcatenateare replaced withflattenConcat,flattenMerge,flatMapConcatandflatMapMerge.- Various documentation improvements and minor bug fixes.
Note that Flow is not leaving its preview status.
Version 1.2.0-alpha-2
This release contains major feature preview: cold streams aka Flow (#254).
Performance:
- Performance of
Dispatcher.Maininitialization is significantly improved (#878).
Version 1.2.0-alpha
- Major debug agent improvements. Real stacktraces are merged with coroutine stacktraces for running coroutines, merging heuristic is improved, API is cleaned up and is on its road to stabilization (#997).
CoroutineTimeoutrule or JUnit4 is introduced to simplify coroutines debugging (#938).- Stacktrace recovery improvements. Exceptions with custom properties are no longer copied,
CopyableThrowableinterface is introduced, machinery is documented (#921, #950). Dispatchers.Unconfined,MainCoroutineDispatcher.immediate,MainScopeandCoroutineScope.cancelare promoted to stable API (#972).CompletableJobis introduced (#971).- Structured concurrency is integrated into futures and listenable futures (#1008).
ensurePresentandisPresentextensions forThreadLocal(#1028).ensureActiveextensions forCoroutineContext,CoroutineScopeandJob(#963).SendChannel.isFullandReceiveChannel.isEmptyare deprecated (#1053).withContextchecks cancellation on entering (#962).- Operator
invokeonCoroutineDispatcher(#428). - Java 8 extensions for
delayandwithTimeoutnow properly handle too large values (#428). - A global exception handler for fatal exceptions in coroutines is introduced (#808, #773).
- Major improvements in cancellation machinery and exceptions delivery consistency. Cancel with custom exception is completely removed.
- Kotlin version is updated to 1.3.21.
- Do not use private API on newer Androids to handle exceptions (#822).
Bug fixes:
- Proper
selectsupport in debug agent (#931). - Proper
supervisorScopesupport in debug agent (#915). - Throwing
initCausedoes no longer trigger an internal error (#933). - Lazy actors are started when calling
closein order to cleanup their resources (#939). - Minor bugs in reactive integrations are fixed (#1008).
- Experimental scheduler shutdown sequence is fixed (#990).
Version 1.1.1
- Maintenance release, no changes in the codebase
- Kotlin is updated to 1.3.20
- Gradle is updated to 4.10
- Native module is published with Gradle metadata v0.4
Version 1.1.0
- Kotlin version updated to 1.3.11.
- Resumes to
CancellableContinuationin the final state produceIllegalStateException(#901). This change does not affect #830, races between resume and cancellation do not lead to an exceptional situation. runBlockingis integrated withDispatchers.Unconfinedby sharing an internal event loop. This change does not affect the semantics of the previously correct code but allows to mix multiplerunBlockingand unconfined tasks (#860).
Version 1.1.0-alpha
Major improvements in coroutines testing and debugging
- New module:
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. - New module:
kotlinx-coroutines-test. Allows setting arbitraryDispatchers.Mainimplementation for tests (#810). - Stacktrace recovery mechanism. Exceptions from coroutines are recovered from current coroutine stacktraces to simplify exception diagnostic. Enabled in debug mode, controlled by
kotlinx.coroutines.debugsystem property (#493).
Other improvements
MainScopefactory andCoroutineScope.cancelextension (#829). One lineCoroutineScopeintegration!CancellableContinuationrace betweenresumeWithExceptionandcancelis addressed, exceptions during cancellation are no longer reported to exception handler (#830, #892).Dispatchers.Defaultnow consumes much less CPU on JVM (#840).- Better diagnostic and fast failure if an uninitialized dispatcher is used (#880).
- Conflated channel becomes linearizable.
- Fixed inconsistent coroutines state when the result of the coroutine had type
DisposableHandle(#835). - Fixed
JavaFxinitialization bug (#816). TimeoutCancellationExceptionis thrown bywithTimeoutinstead ofCancellationExceptionif negative timeout is supplied (#870).- Kotlin/Native single-threaded workers support: coroutines can be safely used in multiple independent K/N workers.
- jsdom support in
Dispatchers.Defaulton JS. - rxFlowable generic parameter is now restricted with Any.
- Guava 27 support in
kotlinx-coroutines-guava. - Coroutines are now built with progressive mode.
- Various fixes in the documentation.
Version 1.0.1
- Align
publisherimplementation with Reactive TCK. - Reimplement
futurecoroutine builders on top ofAbstractCoroutine(#751). - Performance optimizations in
Dispatchers.DefaultandDispatchers.IO. - Use only public API during
JavaFxinstantiation, fixes warnings on Java 9 and build on Java 11 (#463). - Updated contract of
CancellableContinuation.resumeWithException(documentation fix, see #712). - Check cancellation on fast-path of all in-place coroutine builders (
withContext,coroutineScope,supervisorScope,withTimeoutandwithTimeoutOrNull). - Add optional prefix to thread names of
ExperimentalCoroutineDispatcher(#661). - Fixed bug when
ExperimentalCoroutineDispatchercould end up in inconsistent state ifThreadconstructor throws an exception (#748).
Version 1.0.0
- All Kotlin dependencies updated to 1.3 release version.
- Fixed potential memory leak in
HandlerDispatcher.scheduleResumeAfterDelay, thanks @cbeyls. yieldsupport forUnconfinedand immediate dispatchers (#737).- Various documentation improvements.
Version 1.0.0-RC1
- Coroutines API is updated to Kotlin 1.3.
- Deprecated API is removed or marked as
internal. - Experimental and internal coroutine API is marked with corresponding
kotlin.experimental.Experimentalannotation. If you are using@ExperimentalCoroutinesApior@InternalCoroutinesApiyou should explicitly opt-in, otherwise compilation warning (or error) will be produced. Unconfineddispatcher (and all dispatchers which support immediate invocation) forms event-loop on top of current thread, thus preventing allStackOverflowErrors.Unconfineddispatcher is now much safer for the general use and may leave its experimental status soon (#704).- Significantly improved performance of suspending hot loops in
kotlinx.coroutines(#537). - Proguard rules are embedded into coroutines JAR to assist jettifier (#657)
- Fixed bug in shutdown sequence of
runBlocking(#692). ReceiveChannel.receiveOrNullis marked as obsolete and deprecated.Job.cancel(cause)andReceiveChannel.cancel(cause)are deprecated,cancel()returnsUnit(#713).
Version 0.30.2
Dispatchers.Mainis instantiated lazily (see #658 and #665).- Blocking coroutine dispatcher views are now shutdown properly (#678).
- Prevent leaking Kotlin 1.3 from atomicfu dependency (#659).
- Thread-pool based dispatcher factories are marked as obsolete (#261).
- Fixed exception loss on
withContextcancellation (#675).
Version 0.30.1
Maintenance release:
- Added
Dispatchers.Mainto common dispatchers, which can be used from Android, Swing and JavaFx projects if a corresponding integration library is added to dependencies. - With
Dispatchers.Mainimprovement tooling bug in Android Studio #626 is mitigated, so Android users now can safely start the migration to the latestkotlinx.coroutinesversion. - Fixed bug with thread unsafety of shutdown sequence in
EventLoop. - Experimental coroutine dispatcher now has
closecontract similar to JavaExecutor, so it can be safely instantiated and closed multiple times (affects only unit tests). - Atomicfu version is updated with fixes in JS transformer (see #609)
Version 0.30.0
- [Major] Further improvements in exception handling — no failure exception is lost.
asyncand async-like builders cancel parent on failure (it affectsCompletableDeferred, and all reactive integration builders).- This makes parallel decomposition exception-safe and reliable without having to rember about
awaitAll(see #552). Job()wih parent now also cancels parent on failure consistently with other scopes.- All coroutine builders and
Jobimplementations propagate failure to the parent unless it is aCancellationException. - Note, "scoping" builders don't "cancel the parent" verbatim, but rethrow the corresponding exception to the caller for handling.
SupervisorJob()andsupervisorScope { ... }are introduced, allowing for a flexible implementation of custom exception-handling policies, see a new section in the guide on supervision.- Got rid of
awaitAllin documentation and rewrotecurrentScopesection (see #624).
- [Major] Coroutine scheduler is used for
Dispatchers.Defaultby default instead of deprecatedCommonPool.- "
DefaultDispatcher" is used as a public name of the default impl (you'll see it thread names and in the guide). -Dkotlinx.coroutines.scheduler=offcan be used to switch back toCommonPoolfor a time being (until deprecated CommonPool is removed).
- "
- Make
CoroutineStart.ATOMICexperimental as it covers important use-case with resource cleanup in finally block (see #627). - Restored binary compatibility of
Executor.asCoroutineDispatcher(see #629). - Fixed OOM in thread-pool dispatchers (see #571).
- Check for cancellation when starting coroutine with
Dispatchers.Unconfined(see #621). - A bunch of various performance optimizations and docs fixes, including contributions from @AlexanderPrendota, @PaulWoitaschek.
Version 0.27.0
- [Major] Public API revision. All public API was reviewed and marked as preparation to
1.0release:@DeprecatedAPI. All API marked as deprecated will be removed in 1.0 release without replacement.@ExperimentalCoroutinesApiAPI. 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 withinkotlinx.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.- Regular public API. This API is proven to be stable and is not going to be changed. If at some point it will be discovered that such API has unfixable design flaws, it will be gradually deprecated with proper replacement and migration aid, but won't be removed for at least a year.
- [Major] Job state machine is reworked. It includes various performance improvements, fixes in
data-races which could appear in a rare circumstances and consolidation of cancellation and exception handling.
Visible consequences of include more robust exception handling for large coroutines hierarchies and for different kinds of
CancellationException, transparent parallel decomposition and consistent view of coroutines hierarchy in terms of its state (see #220 and #585). - NIO, Quasar and Rx1 integration modules are removed with no replacement (see #595, #601, #603).
withContextis now aligned with structured concurrency and awaits for all launched tasks, its performance is significantly improved (see #553 and #617).- Added integration module with Play Services Task API. Thanks @SUPERCILEX and @lucasvalenteds for the contribution!
- Integration with Rx2 now respects nullability in type constraints (see #347). Thanks @Dmitry-Borodin for the contribution!
CompletableFuture.awaitandListenableFuture.awaitnow propagate cancellation to the future (see #611).- Cancellation of
runBlockingmachinery is improved (see #589). - Coroutine guide is restructured and split to multiple files for the sake of simplicity.
CoroutineScopefactory methods addJobif it is missing from the context to enforce structured concurrency (see #610).Handler.asCoroutineDispatcherhas anameparameter for better debugging (see #615).- Fixed bug when
CoroutineSchedulewas closed from one of its threads (see #612). - Exceptions from
CoroutineExceptionHandlerare reported by default exception handler (see #562). CoroutineNameis now available from common modules (see #570).- Update to Kotlin 1.2.70.
Version 0.26.1
- Android
Maindispatcher isasyncby default which may significantly improve UI performance. Contributed by @JakeWharton (see #427). - Fixed bug when lazily-started coroutine with registered cancellation handler was concurrently started and cancelled.
- Improved termination sequence in IO dispatcher.
- Fixed bug with
CoroutineScope.plusoperator (see #559). - Various fixes in the documentation. Thanks to @SUPERCILEX, @yorlov, @dualscyther and @soudmaijer!
Version 0.26.0
- Major rework of
kotlinx.coroutinesconcurrency model (see #410 for a full explanation of the rationale behind this change):- All coroutine builders are now extensions on
CoroutineScopeand inherit itscoroutineContext. Standalone builders are deprecated. - As a consequence, all nested coroutines launched via builders now automatically establish parent-child relationship and inherit
CoroutineDispatcher. - All coroutine builders use
Dispatchers.Defaultby default ifCoroutineInterceptoris not present in their context. - CoroutineScope became the first-class citizen in
kolinx.coroutines. withContextblockargument hasCoroutineScopeas a receiver.- GlobalScope is introduced to simplify migration to new API and to launch global-level coroutines.
currentScopeandcoroutineScopebuilders are introduced to extract and provideCoroutineScope.- Factory methods to create
CoroutineScopefromCoroutineContextare introduced. CoroutineScope.isActivebecame an extension property.- New sections about structured concurrency in core guide: "Structured concurrency", "Scope builder" and "Structured concurrency with async".
- New section in UI guide with Android example: "Structured concurrency, lifecycle and coroutine parent-child hierarchy".
- Deprecated reactive API is removed.
- All coroutine builders are now extensions on
- Dispatchers are renamed and grouped in the Dispatchers object (see #41 and #533):
- Dispatcher names are consistent.
- Old dispatchers including
CommonPoolare deprecated.
- Fixed bug with JS error in rare cases in
invokeOnCompletion(onCancelling = true). - Fixed loading of Android exception handler when
Thread.contextClassLoaderis mocked (see #530). - Fixed bug when
IOdispatcher silently hung (see #524 and #525) .
Version 0.25.3
- Distribution no longer uses multi-version jar which is not supported on Android (see #510).
- JS version of the library does not depend on AtomicFu anymore: All the atomic boxes in JS are fully erased.
- Note that versions 0.25.1-2 are skipped for technical reasons (they were not fully released).
Version 0.25.0
- Major rework on exception-handling and cancellation in coroutines (see #333, #452 and #451):
- New "Exception Handling" section in the guide explains exceptions in coroutines.
- Semantics of
Job.cancelresultingBooleanvalue changed —truemeans exception was handled by the job, caller shall handle otherwise. - Exceptions are properly propagated from children to parents.
- Installed
CoroutineExceptionHandlerfor a family of coroutines receives one aggregated exception in case of failure. - Change
handleCoroutineExceptioncontract, so custom exception handlers can't break coroutines machinery. - Unwrap
JobCancellationExceptionproperly to provide exception transparency over whole call chain.
- Introduced support for thread-local elements in coroutines context (see #119):
ThreadContextElementAPI for custom thread-context sensitive context elements.ThreadLocal.asContextElement()extension function to convert an arbitrary thread-local into coroutine context element.- New "Thread-local data" subsection in the guide with examples.
- SLF4J Mapped Diagnostic Context (MDC) integration is provided via
MDCContextelement defined inkotlinx-coroutines-slf4jintegration module.
- Introduced IO dispatcher to offload blocking I/O-intensive tasks (see #79).
- Introduced
ExecutorCoroutineDispatcherinstead ofCloseableCoroutineDispatcher(see #385). - Built with Kotlin 1.2.61 and Kotlin/Native 0.8.2.
- JAR files for
kotlinx-coroutinesare now JEP 238 multi-release JAR files.- On JDK9+
VarHandleis used for atomic operations instead ofAtomic*FieldUpdaterfor better performance. - See AtomicFu project for details.
- On JDK9+
- Reversed addition of
BlockingCheckerextension point to control whererunBlockingcan be used (see #227).runBlockingcan be used anywhere without limitations (again), but it would still cause problems if improperly used on UI thread.
- Corrected return-type of
EventLooppseudo-constructor (see #477, PR by @Groostav). - Fixed
as*Future()integration functions to catch allThrowableexceptions (see #469). - Fixed
runBlockingcancellation (see #501). - Fixed races and timing bugs in
withTimeoutOrNull(see #498). - Execute
EventLoop.invokeOnTimeoutinDefaultDispatcherto allow busy-wait loops insiderunBlocking(see #479). - Removed
kotlinx-coroutines-iomodule from the project, it has moved to kotlinx-io. - Provide experimental API to create limited view of experimental dispatcher (see #475).
- Various minor fixes by @LouisCAD, @Dmitry-Borodin.
Version 0.24.0
- Fully multiplatform release with Kotlin/Native support (see #246):
- Only single-threaded operation inside
runBlockingevent loop is supported at this moment. - See details on setting up build environment here.
- Only single-threaded operation inside
- Improved channels:
- Introduced
SendChannel.invokeOnClose(see #341). - Make
close,cancel,isClosedForSend,isClosedForReceiveandofferlinearizable with other operations (see #359). - Fixed bug when send operation can be stuck in channel forever.
- Fixed broadcast channels on JS (see #412).
- Introduced
- Provides
BlockingCheckermechanism which checks current context (see #227).- Attempts to use
runBlockingfrom any supported UI thread (Android, JavaFx, Swing) will result in exception.
- Attempts to use
- Android:
- Worked around Android bugs with zero-size ForkJoinPool initialization (see #432, #288).
- Introduced
UI.immediateextension as performance-optimization to immediately execute tasks which are invoked from the UI thread (see #381).- Use it only when absolutely needed. It breaks asynchrony of coroutines and may lead to surprising and unexpected results.
- Fixed materialization of a
causeexception forJobonCancelling handlers (see #436). - Fixed JavaFx
UIon Java 9 (see #443). - Fixed and documented the order between cancellation handlers and continuation resume (see #415).
- Fixed resumption of cancelled continuation (see #450).
- Includes multiple fixes to documentation contributed by @paolop, @SahilLone, @rocketraman, @bdavisx, @mtopolnik, @Groostav.
- Experimental coroutines scheduler preview (JVM only):
- Written from scratch and optimized for communicating coroutines.
- Performs significantly better than ForkJoinPool on coroutine benchmarks and for connected applications with ktor.
- Supports automatic creating of new threads for blocking operations running on the same thread pool (with an eye on solving #79), but there is no stable public API for it just yet.
- For preview, run JVM with
-Dkotlinx.coroutines.scheduleroption. In this caseDefaultDispatcheris set to new experimental scheduler instead of FJP-basedCommonPool. - Submit your feedback to issue #261.
Version 0.23.4
- Recompiled with Kotlin 1.2.51 to solve broken metadata problem (see KT-24944).
Version 0.23.3
- Kotlin 1.2.50.
- JS: Moved to atomicfu version 0.10.3 that properly matches NPM & Kotlin/JS module names (see #396).
- Improve source-code compatibility with previous (0.22.x) version of
openChannel().use { ... }pattern by providing deprecated extension functionuseonReceiveChannel.
Version 0.23.2
- IO: fix joining and continuous writing byte array interference.
Version 0.23.1
- JS: Fix dependencies in NPM: add "kotlinx-atomicfu" dependency (see #370).
- Introduce
broadcastcoroutine builder (see #280):- Support
BroadcastChannel.cancelmethod to drop the buffer. - Introduce
ReceiveChannel.broadcast()extension.
- Support
- Fixed a bunch of doc typos (PRs by @paolop).
- Corrected previous version's release notes (PR by @ansman).
Version 0.23.0
- Kotlin 1.2.41
- Coroutines core module is made mostly cross-platform for JVM and JS:
- Migrate channels and related operators to common, so channels can be used from JS (see #201).
- Most of the code is shared between JVM and JS versions using cross-platform version of AtomicFU library.
- The recent version of Kotlin allows default parameters in common code (see #348).
- The project is built using Gradle 4.6.
- Breaking change:
CancellableContinuationis not aJobanymore (see #219):- It does not affect casual users of
suspendCancellableCoroutine, since all the typically used functions are still there. CancellableContinuation.invokeOnCompletionis deprecated now and its semantics had subtly changed:invokeOnCancellationis a replacement forinvokeOnCompletionto install a handler.- The handler is not invoked on
resumewhich corresponds to the typical usage pattern. - There is no need to check for
cont.isCancelledin a typical handler code anymore (since handler is invoked only when continuation is cancelled). - Multiple cancellation handlers cannot be installed.
- Cancellation handlers cannot be removed (disposed of) anymore.
- This change is designed to allow better performance of suspending cancellable functions:
- Now
CancellableContinuationimplementation has simpler state machine and is implemented more efficiently.
- Now
- Exception handling in
AbstractContinuation(that implementsCancellableContinuation) is now consistent:- Always prefer exception thrown from coroutine as exceptional reason, add cancellation cause as suppressed exception.
- It does not affect casual users of
- Big change: Deprecate
CoroutineScope.coroutineContext:- It is replaced with top-level
coroutineContextfunction from Kotlin standard library.
- It is replaced with top-level
- Improve
ReceiveChanneloperators implementations to guarantee closing of the source channels under all circumstances (see #279):onCompletionparameter added toproduceand all other coroutine builders.- Introduce
ReceiveChannel.consumes(): CompletionHandlerextension function.
- Replace
SubscriptionReceiveChannelwithReceiveChannel(see #283, PR by @deva666).ReceiveChannel.useextension is introduced to preserve source compatibility, but is deprecated.consumeorconsumeEachextensions should be used for channels.- When writing operators,
produce(onCompletion=consumes()) { ... }pattern shall be used (see #279 above).
- JS: Kotlin is declared as peer dependency (see #339, #340, PR by @ansman).
- Invoke exception handler for actor on cancellation even when channel was successfully closed, so exceptions thrown by actor are always reported (see #368).
- Introduce
awaitAllandjoinAllforDeferredandJoblists correspondingly (see #171). - Unwrap
CompletionExceptionexception inCompletionStage.awaitslow-path to provide consistent results (see #375). - Add extension to
ExecutorServiceto returnCloseableCoroutineDispatcher(see #278, PR by @deva666). - Fail with proper message during build if JDK_16 is not set (see #291, PR by @venkatperi).
- Allow negative timeouts in
delay,withTimeoutandonTimeout(see #310). - Fix a few bugs (leaks on cancellation) in
delay:- Invoke
clearTimeouton cancellation in JSDispatcher. - Remove delayed task on cancellation from internal data structure on JVM.
- Invoke
- Introduce
tickerfunction to create "ticker channels" (see #327):- It provides analogue of RX
Observable.timerfor coroutine channels. - It is currently supported on JVM only.
- It provides analogue of RX
- Add a test-helper class
TestCoroutineContext(see #297, PR by @streetsofboston).- It is currently supported on JVM only.
- Ticker channels (#327) are not yet compatible with it.
- Implement a better way to set
CoroutineContext.DEBUGvalue (see #316, PR by @dmytrodanylyk):- Made
CoroutineContext.DEBUG_PROPERTY_NAMEconstant public. - Introduce public constants with
"on","off","auto"values.
- Made
- Introduce system property to control
CommonPoolparallelism (see #343):CommonPool.DEFAULT_PARALLELISM_PROPERTY_NAMEconstant is introduced with a value of "kotlinx.coroutines.default.parallelism".
- Include package-list files into documentation site (see #290).
- Fix various typos in docs (PRs by @paolop and @ArtsiomCh).
Version 0.22.5
- JS: Fixed main file reference in NPM package
- Added context argument to
Channel.filterNot(PR by @jcornaz). - Implemented debug
toStringfor channels (see #185).
Version 0.22.4
- JS: Publish to NPM (see #229).
- JS: Use node-style dispatcher on ReactNative (see #236).
- jdk8 integration improvements:
- Added conversion from
CompletionStagetoDeferred(see #262, PR by @jcornaz). - Use fast path in
CompletionStage.awaitand make it cancellable.
- Added conversion from
Version 0.22.3
- Fixed
producebuilder to close the channel on completion instead of cancelling it, which lead to lost elements with buffered channels (see #256). - Don't use
ForkJoinPoolif there is aSecurityManagerpresent to work around JNLP problems (see #216, PR by @NikolayMetchev). - JS: Check for undefined
window.addEventListenerwhen choosing default coroutine dispatcher (see #230, PR by @ScottPierce). - Update 3rd party dependencies:
- kotlinx-coroutines-rx1 to RxJava version
1.3.6. - kotlinx-coroutines-rx2 to RxJava version
2.1.9. - kotlinx-coroutines-guava to Guava version
24.0-jre.
- kotlinx-coroutines-rx1 to RxJava version
Version 0.22.2
- Android: Use @Keep annotation on AndroidExceptionPreHandler to fix the problem on Android with minification enabled (see #214).
- Reactive: Added
awaitFirstOrDefaultandawaitFirstOrNullextensions (see #224, PR by @konrad-kaminski). - Core: Fixed
withTimeoutandwithTimeoutOrNullthat should not use equals on result (see #212, PR by @konrad-kaminski). - Core: Fixed hanged receive from a closed subscription of BroadcastChannel (see #226).
- IO: fixed error propagation (see https://github.com/ktorio/ktor/issues/301).
- Include common sources into sources jar file to work around KT-20971.
- Fixed bugs in documentation due to MPP.
Version 0.22.1
- Migrated to Kotlin 1.2.21.
- Improved
actorbuilder documentation (see #210) and fixed bugs in rendered documentation due to multiplatform. - Fixed
runBlockingto properly support specified dispatchers (see #209). - Fixed data race in
Jobimplementation (it was hanging atLockFreeLinkedList.helpDeleteon certain stress tests). AbstractCoroutine.onCancellationis invoked before cancellation handler that is set viainvokeOnCompletion.- Ensure that
launchhandles uncaught exception before another coroutine that usesjoinon it resumes (see #208).
Version 0.22
- Migrated to Kotlin 1.2.20.
- Introduced stable public API for
AbstractCoroutine:- Implements
Job,Continuation, andCoroutineScope. - Has overridable
onStart,onCancellation,onCompletedandonCompletedExceptionallyfunctions. - Reactive integration modules are now implemented using public API only.
- Notifies onXXX before all the installed handlers, so
launchhandles uncaught exceptions before "joining" coroutines wakeup (see #208).
- Implements
Version 0.21.2
- Fixed
openSubscriptionextension for reactivePublisher/Observable/Flowablewhen used withselect { ... }and added an optionalrequestparameter to specify how many elements are requested from publisher in advance on subscription (see #197). - Simplified implementation of
Channel.flatMapusingtoChannelfunction to work around Android 5.0 APK install SIGSEGV (see #205).
Version 0.21.1
- Improved performance of coroutine dispatching (
DispatchTaskinstance is no longer allocated). - Fixed
Job.cancelandCompletableDeferred.completeto support cancelling/completing states and properly wait for their children to complete on join/await (see #199). - Fixed a bug in binary heap implementation (used internally by
delay) which could have resulted in wrong delay time in rare circumstances. - Coroutines library for Kotlin/JS:
Promise.asDeferredimmediately installs handlers to avoid "Unhandled promise rejection" warning.- Use
window.postMessageinstead ofsetTimeoutfor coroutines inside the browser to avoid timeout throttling (see #194). - Use custom queue in
Window.awaitAnimationFrameto align all animations and reduce overhead. - Introduced
Window.asCoroutineDispatcher()extension function.
Version 0.21
- Migrated to Kotlin 1.2.10.
- Coroutines library for Kotlin/JS and multiplatform projects (see #33):
launchandasynccoroutine builders.JobandDeferredlight-weight future with cancellation support.delayandyieldtop-level suspending functions.awaitextension for JSPromiseandasPromise/asDeferredconversions.promisecoroutine builder.Job()andCompletableDeferred()factories.- Full support for parent-child coroutine hierarchies.
Window.awaitAnimationFrameextension function.- Sample frontend Kotlin/JS application with coroutine-driven animations.
runis deprecated and renamed towithContext(see #134).runBlockingandEventLoopimplementations optimized (see #190).
Version 0.20
- Migrated to Kotlin 1.2.0.
- Channels:
- Sequence-like
filter,map, etc extensions onReceiveChannelare introduced (see #88 by @fvasco and #69 by @konrad-kaminski). - Introduced
ReceiveChannel.cancelmethod. - All operators on
ReceiveChannelfully consume the original channel (cancelit when they are done) using a helperconsumeextension. - Deprecated
ActorJobandProducerJob;actornow returnsSendChannelandproducereturnsReceiveChannel(see #127). SendChannel.sendBlockingextension method (see #157 by @@fvasco).
- Sequence-like
- Parent-child relations between coroutines:
- Introduced an optional
parentjob parameter for all coroutine builders so that code with an explict parentJobis more natural. - Added
parentparameter toCompletableDeferredconstructor. - Introduced
Job.childrenproperty. Job.cancelChildrenis now an extension (member is deprecated and hidden).Job.joinChildrenextension is introduced.- Deprecated
Job.attachChildas a error-prone API. - Fixed StackOverflow when waiting for a lot of completed children that did not remove their handlers from the parent.
- Introduced an optional
- Use
java.util.ServiceLoaderto find default instances ofCoroutineExceptionHandler. - Android UI integration:
- Use
Thread.getUncaughtExceptionPreHandlerto make sure that exceptions are logged before crash (see #148). - Introduce
UI.awaitFramefor animation; added sample coroutine-based animation application for Android here. - Fixed
delay(Long.MAX_VALUE)(see #161)
- Use
- Added missing
DefaultDispatcheron some reactive operators (see #174 by @fvasco) - Fixed
actorandproduceso that a cancellation of a Job cancels the underlying channel (closes and removes all the pending messages). - Fixed sporadic failure of
example-context-06(see #160) - Fixed hang of
Job.starton lazy coroutine with attachedinvokeOnCompletionhandler. - A more gradual introduction to
runBlockingand coroutines in the guide (see #166).
Version 0.19.3
- Fixed
send/openSubscriptionrace inArrayBroadcastChannel. This race lead to stalled (hanged)send/receiveinvocations. - Project build has been migrated to Gradle.
Version 0.19.2
- Fixed
ArrayBroadcastChannelreceive of stale elements onopenSubscription. Only elements that are sent after invocation ofopenSubscriptionare received now. - Added a default value for
contextparameter torxFlowable(see #146 by @PhilGlass). - Exception propagation logic from cancelled coroutines is adjusted (see #152):
- When cancelled coroutine crashes due to some other exception, this other exception becomes the cancellation reason of the coroutine, while the original cancellation reason is suppressed.
UnexpectedCoroutineExceptionis no longer used to report those cases as is removed.- This fixes a race between crash of CPU-consuming coroutine and cancellation which resulted in an unhandled exception and lead to crashes on Android.
runuses cancelling state & propagates exceptions when cancelled (see #147):- When coroutine that was switched into a different dispatcher using
runis cancelled, the run invocation does not complete immediately, but waits until the body completes. - If the body completes with exception, then this exception is propagated.
- When coroutine that was switched into a different dispatcher using
- No
JobinnewSingleThreadContextandnewFixedThreadPoolContextanymore (see #149, #151):- This resolves the common issue of using
run(ctx)where ctx comes from eithernewSingleThreadContextornewFixedThreadPoolContextinvocation. 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. ThreadPoolDispatcherclass is now public and is the result type for both functions. It has theclosemethod to release the thread pool.
- This resolves the common issue of using
Version 0.19.1
- Failed parent Job cancels all children jobs, then waits for them them.
This makes parent-child hierarchies easier to get working right without
having to use
try/catchor other exception handlers. - Fixed a race in
ArrayBroadcastChannelbetweensendandopenChannelinvocations (see #138). - Fixed quite a rare race in
runBlockingthat resulted inAssertionError. Unfortunately, cannot write a reliable stress-test to reproduce it. - Updated Reactor support to leverage Bismuth release train (contributed by @sdeleuze, see PR #141)
Version 0.19
- This release is published to Maven Central.
DefaultDispatcheris introduced (see #136):launch,async,produce,actorand other integration-specific coroutine builders now useDefaultDispatcheras the default value for theircontextparameter.- When a context is explicitly specified,
newCoroutineContextfunction checks if there is any interceptor/dispatcher defined in the context and usesDefaultDispatcherif there is none. DefaultDispatcheris currently defined to be equal toCommonPool.- Examples in the guide now start with
launch { ... }code and explanation on the nature and the need for coroutine context starts in "Coroutine context and dispatchers" section.
- Parent coroutines now wait for their children (see #125):
- Job completing state is introduced in documentation as a state in which parent coroutine waits for its children.
Job.attachChildandJob.cancelChildrenare introduced.Job.joinnow always checks cancellation status of invoker coroutine for predictable behavior when joining failed child coroutine.Job.cancelAndJoinextension is introduced.CoroutineContext.cancelandCoroutineContext.cancelChildrenextensions are introduced for convenience.withTimeout/withTimeoutOrNullblocks become proper coroutines that haveCoroutineScopeand wait for children, too.- Diagnostics in cancellation and unexpected exception messages are improved, coroutine name is included in debug mode.
- Fixed cancellable suspending functions to throw
CancellationException(as was documented before) even when the coroutine is cancelled with another application-specific exception. JobCancellationExceptionis introduced as a specific subclass ofCancellationExceptionwhich is used for coroutines that are cancelled without cause and to wrap application-specific exceptions.Job.getCompletionExceptionis renamed toJob.getCancellationExceptionand return a wrapper exception if needed.- Introduced
Deferred.getCompletionExceptionOrNullto get not-wrapped exception result ofasynctask. - Updated docs for
Job&Deferredto explain parent/child relations.
selectexpression 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 theSelectBuilderinkotlinx-corounes-coremodule.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.- This opens road to moving channels into a separate module in future updates.
- Renamed
TimeoutExceptiontoTimeoutCancellationException(old name is deprecated). - Fixed various minor problems:
- JavaFx toolkit is now initialized by
JavaFxcontext (see #108). - Fixed lost ACC_STATIC on methods (see #116).
- Fixed link to source code from documentation (see #129).
- Fixed
delayin arbitrary contexts (see #133).
- JavaFx toolkit is now initialized by
kotlinx-coroutines-iomodule is introduced. It is a work-in-progress onByteReadChannelandByteWriteChannelinterfaces, 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.
Version 0.18
- Kotlin 1.1.4 is required to use this version, which enables:
withLockandconsumeEachfunctions are now inline suspend functions.JobSupportclass implementation is optimized (one fewer field).
TimeoutExceptionis public (see #89).- Improvements to
Mutex(courtesy of @fvasco):- Introduced
holdsLock(see #92). - Improved documentation on
Mutexfairness (see #90).
- Introduced
- Fixed NPE when
ArrayBroadcastChannelis closed concurrently with receive (see #97). - Fixed bug in internal class LockFreeLinkedList that resulted in ISE under stress in extremely rare circumstances.
- Integrations:
- quasar: Introduced integration with suspendable JVM functions that are instrumented with Parallel Universe Quasar (thanks to the help of @pron).
- reactor: Replaced deprecated
setCancellationwithonDiposeand updated to Aluminium-SR3 release (courtesy of @yxf07, see #96) - jdk8: Added adapters for
java.timeclasses (courtesy of @fvasco, see #93)
Version 0.17
CompletableDeferredis introduced as a set-once event-like communication primitive (see #70).- Coroutines guide uses it in a section on actors.
CompletableDeferredis an interface with private impl (courtesy of @fvasco, see #86).- It extends
Deferredinterface withcompleteandcompleteExceptionallyfunctions.
Job.joinandDeferred.awaitwait until a cancelled coroutine stops execution (see #64).JobandDeferredhave a new cancelling state which they enter on invocation ofcancel.Job.invokeOnCompletionhas an additional overload withonCancelling: Booleanparameter to install handlers that are fired as soon as coroutine enters cancelling state as opposed to waiting until it completes.- Internal
selectimplementation is refactored to decouple it fromJobSupportinternal class and to optimize its state-machine. - Internal
AbstractCoroutineclass is refactored so that it is extended only by true coroutines, all of which support the new cancelling state.
CoroutineScope.contextis renamed tocoroutineContextto avoid conflicts with other usages ofcontextin applications (like Android context, see #75).BroadcastChannel.openis renamed toopenSubscription(see #54).- Fixed
StackOverflowErrorin a convoy ofMutex.unlockinvokers withUnconfineddispatcher (see #80). - Fixed
SecurityExceptionwhen trying to use coroutines library with installedSecurityManager. - Fixed a bug in
withTimeoutOrNullin case with nested timeouts when coroutine was cancelled before it was ever suspended. - Fixed a minor problem with
awaitFirston reactive streams that would have resulted in spurious stack-traces printed on the console when used with publishers/observables that continue to invokeonNextdespite being cancelled/disposed (which they are technically allowed to do by specification). - All factory functions for various interfaces are implemented as top-level functions
(affects
Job,Channel,BroadcastChannel,Mutex,EventLoop, andCoroutineExceptionHandler). Previous approach of usingoperator invokeon their companion objects is deprecated. - Nicer-to-use debug
toStringimplementations for coroutine dispatcher tasks and continuations. - A default dispatcher for
delayis rewritten and now shares code withEventLoopImplthat is used byrunBlocking. It internally supports non-defaultTimeSourceso 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).
Version 0.16
- Coroutines that are scheduled for execution are cancellable by default now
suspendAtomicCancellableCoroutinefunction is introduced for funs likesend/receive/receiveOrNullthat require atomic cancellation (they cannot be cancelled after decision was made)- Coroutines started with default mode using
async/launch/actorbuilders can be cancelled before their execution starts CoroutineStart.ATOMICis introduced as a start mode to specify that coroutine cannot be cancelled before its execution startsrunfunction is also cancellable in the same way and accepts an optionalCoroutineStartparameter to change this default.
BroadcastChannelfactory function is introducedCoroutineExceptionHandlerfactory function is introduced by @konrad-kaminskiintegrationdirectory is introduced for all 3rd party integration projects- It has contribution guidelines and contributions from community are welcome
- Support for Guava
ListenableFuturein the newkotlinx-coroutines-guavamodule - Rx1 Scheduler support by @konrad-kaminski
- Fixed a number of
ChannelandBroadcastChannelimplementation 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. - Fixed
withTimeoutOrNullwhich was returningnullon timeout of inner or outerwithTimeoutblocks (see #67). Thanks to @gregschlom for finding the problem. - Fixed a bug where
Jobfails to dispose a handler when it is the only handler by @uchuhimo
Version 0.15
- Switched to Kotlin version 1.1.2 (can still be used with 1.1.0).
CoroutineStartenum is introduced forlaunch/async/actorbuilders:- The usage of
luanch(context, start = false)is deprecated and is replaced withlaunch(context, CoroutineStart.LAZY) CoroutineStart.UNDISPATCHEDis introduced to start coroutine execution immediately in the invoker thread, so thatasync(context, CoroutineStart.UNDISPATCHED)is similar to the behavior of C#async.- Guide to UI programming with coroutines mentions the use of it to optimize the start of coroutines from UI threads.
- The usage of
- Introduced
BroadcastChannelinterface inkotlinx-coroutines-coremodule:- It extends
SendChannelinterface and providesopenfunction to create subscriptions. - Subscriptions are represented with
SubscriptionReceiveChannelinterface. - The corresponding
SubscriptionReceiveChannelinterfaces are removed from reactive implementation modules. They use an interface defined inkotlinx-coroutines-coremodule. ConflatedBroadcastChannelimplementation 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.ArrayBroadcastChannelimplementation is provided for event-bus-like use-cases, where a sequence of events shall be received by multiple subscribers without any omissions.- Guide to reactive streams with coroutines includes "Rx Subject vs BroadcastChannel" section.
- It extends
- Pull requests from Konrad Kamiński are merged into reactive stream implementations:
- Support for Project Reactor
MonoandFlux. Seekotlinx-coroutines-reactormodule. - Implemented Rx1
Completable.awaitCompleted. - Added support for Rx2
Maybe.
- Support for Project Reactor
- Better timeout support:
- Introduced
withTimeoutOrNullfunction. - Implemented
onTimeoutclause forselectexpressions. - Fixed spurious concurrency inside
withTimeoutblocks on their cancellation. - Changed behavior of
withTimeoutwhenCancellationExceptionis suppressed inside the block. Invocation ofwithTimeoutnow always returns the result of execution of its inner block.
- Introduced
- The
channelproperty inActorScopeis promoted to a widerChanneltype, so that an actor can have an easy access to its own inbox send channel. - Renamed
Mutex.withMutextoMutex.withLock, old name is deprecated.
Version 0.14
- Switched to Kotlin version 1.1.1 (can still be used with 1.1.0).
- Introduced
consumeEachhelper function for channels and reactive streams, Rx 1.x, and Rx 2.x.- It ensures that streams are unsubscribed from on any exception.
- Iteration with
forloop on reactive streams is deprecated. - Guide to reactive streams with coroutines is updated virtually all over the place to reflect these important changes.
- Implemented
awaitFirstOrDefaultextension for reactive streams, Rx 1.x, and Rx 2.x. - Added
Mutex.withMutexhelper function. kotlinx-coroutines-androidmodule hasprovideddependency on of Android APIs to eliminate warnings when using it in android project.
Version 0.13
- New
kotlinx-coroutinex-androidmodule with AndroidUIcontext implementation. - Introduced
whileSelectconvenience function. - Implemented
ConflatedChannel. - Renamed various
toXXXconversion functions toasXXX(old names are deprecated). runis optimized with fast-path case and no longer hasCoroutineScopein its block.- Fixed dispatching logic of
withTimeout(removed extra dispatch). EventLoopthat is used byrunBlockingnow implements Delay, giving more predictable test behavior.- Various refactorings related to resource management and timeouts:
Job.Registrationis renamed toDisposableHandle.EmptyRegistrationis renamed toNonDisposableHandle.Job.unregisterOnCompletionis renamed toJob.disposeOnCompletion.Delay.invokeOnTimeoutis introduced.withTimeoutnow usesDelay.invokeOnTimeoutwhen available.
- A number of improvement for reactive streams and Rx:
- Introduced
rxFlowablebuilder for Rx 2.x. Scheduler.asCoroutineDispatcherextension for Rx 2.x.- Fixed bug with sometimes missing
onCompleteinpublish,rxObservable, andrxFlowablebuilders. - Channels that are open for reactive streams are now
Closeable. - Fixed
CompletableSource.awaitand added test for it. - Removed
rx.Completable.awaitdue to name conflict.
- Introduced
- New documentation:
- Code is published to JCenter repository.
Version 0.12
- Switched to Kotlin version 1.1.0 release.
- Reworked and updated utilities for Reactive Streams, Rx 1.x, and Rx 2.x with library-specific coroutine builders, suspending functions, converters and iteration support.
LinkedListChannelwith unlimited buffer (offeralways succeeds).onLockselect clause and an optionalownerparameter in allMutexfunctions.selectUnbiasedfunction.actorcoroutine builder.- Couple more examples for "Shared mutable state and concurrency" section and "Channels are fair" section with ping-pong table example in coroutines guide.
Version 0.11-rc
selectexpression with onJoin/onAwait/onSend/onReceive clauses.Mutexis moved tokotlinx.coroutines.syncpackage.ClosedSendChannelExceptionis a subclass ofCancellationExceptionnow.- New sections on "Shared mutable state and concurrency" and "Select expression" in coroutines guide.
Version 0.10-rc
- Switched to Kotlin version 1.1.0-rc-91.
Mutexsynchronization primitive is introduced.buildChannelis renamed toproduce, old name is deprecated.Job.onCompletionis renamed toJob.invokeOnCompletion, old name is deprecated.delayimplementation in Swing, JavaFx, and scheduled executors is fixed to avoid an extra dispatch.CancellableContinuation.resumeUndispatchedis introduced to make this efficient implementation possible.- Remove unnecessary creation of
CancellationExceptionto improve performance, plus other performance improvements. - Suppress deprecated and internal APIs from docs.
- Better docs at top level with categorized summary of classes and functions.
Version 0.8-beta
defercoroutine builder is renamed toasync.lazyDeferis deprecated,asynchas an optionalstartparameter instead.LazyDeferredinterface is deprecated, lazy start functionality is integrated intoJobinterface.launchhas an optionalstartparameter for lazily started coroutines.Job.startandJob.isCompletedare introduced.Deferred.isCompletedExceptionallyandDeferred.isCancelledare introduced.Job.getInactiveCancellationExceptionis renamed togetCompletionException.Job.joinis now a member function.- Internal
JobSupportstate 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. - Exception transparency in
Job.cancel(original cause is rethrown). - Clarified possible states for
Job/CancellableContinuation/Deferredin docs. - Example on async-style functions and links to API reference site from coroutines guide.
Version 0.7-beta
- Buffered and unbuffered channels are introduced:
Channel,SendChannel, andReceiveChannelinterfaces,RendezvousChannelandArrayChannelimplementations,Channel()factory function andbuildChannel{}coroutines builder. Herecontext is renamed toUnconfined(the old name is deprecated).- A guide on coroutines is expanded: sections on contexts and channels.
Version 0.6-beta
- Switched to Kotlin version 1.1.0-beta-37.
- A guide on coroutines is expanded.
Version 0.5-beta
- Switched to Kotlin version 1.1.0-beta-22 (republished version).
- Removed
currentCoroutineContextand related thread-locals without replacement. Explicitly pass coroutine context around if needed. lazyDefer(context) {...}coroutine builder andLazyDeferredinterface are introduced.- The default behaviour of all coroutine dispatchers is changed to always schedule execution of new coroutine
for later in this thread or thread pool. Correspondingly,
CoroutineDispatcher.isDispatchNeededfunction has a default implementation that returnstrue. NonCancellablecontext is introduced.- Performance optimizations for cancellable continuations (fewer objects created).
- A guide on coroutines is added.
Version 0.4-beta
- Switched to Kotlin version 1.1.0-beta-18 (republished version).
CoroutineDispatchermethods now havecontextparameter.- Introduced
CancellableContinuation.isCancelled - Introduced
EventLoopdispatcher and made it a default forrunBlocking { ... } - Introduced
CoroutineScopeinterface withisActiveandcontextproperties; standard coroutine builders include it as receiver for convenience. - Introduced
Executor.toCoroutineDispatcher()extension. - Delay scheduler thread is not daemon anymore, but times out automatically.
- Debugging facilities in
newCoroutineContextcan be explicitly disabled with-Dkotlinx.coroutines.debug=off. - xxx-test files are renamed to xxx-example for clarity.
- Fixed NPE in Job implementation when starting coroutine with already cancelled parent job.
- Support cancellation in
kotlinx-coroutines-niomodule