Releases: Kotlin/kotlinx.coroutines
Releases · Kotlin/kotlinx.coroutines
0.16
- Coroutines that are scheduled for execution are cancellable by default now
suspendAtomicCancellableCoroutinefunction is introduced for funs like
send/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 optional
CoroutineStartparameter to change this default.
BroadcastChannelfactory function is introducedCorouiteExceptionHandlerfactory 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
- #66 Fixed a number of
ChannelandBroadcastChannelimplementation bugs related to concurrent send/close/close of channels that lead to hanging send, offer or close operations.
Thanks to @chrisly42 and @cy6erGn0m for finding them. - #67 Fixed
withTimeoutOrNullwhich was returningnullon timeout of inner or outerwithTimeoutblocks.
Thanks to @gregschlom for finding the problem. - Fixed a bug where
Jobfails to dispose a handler when it is the only handler by @uchuhimo
0.15
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 with
launch(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 the behavior of
withTimeoutwhenCancellationExceptionis suppressed inside the block. The
invocation ofwithTimeoutnow always returns the result of the 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.
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
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 toDisposableHandleEmptyRegistrationis renamed toNonDisposableHandleJob.unregisterOnCompletionis renamed toJob.disposeOnCompletionDelay.invokeOnTimeoutis introducedwithTimeoutnow 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
0.12: Kotlin 1.1.0 release and reactive utilities
- 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.
0.11-rc: select
selectexpression with onJoin/onAwait/onSend/onReceive clauses.Mutexis moved tokotlinx.coroutines.experimental.syncpackage.ClosedSendChannelExceptionis a subclass ofCancellationExceptionnow.- New sections on "Shared mutable state and concurrency" and "Select expression"
in coroutines guide.
0.10-rc: Mutex & Kotlin 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.
0.8-beta: async and other maintanance
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.
0.7-beta: Channels
- 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.
0.6-beta: for Kotlin 1.1.0-beta-38
- Switched to Kotlin version 1.1.0-beta-38.
- A guide on coroutines is expanded.