Skip to content

Releases: Kotlin/kotlinx.coroutines

0.21.2

15 Jan 12:21
Compare
Choose a tag to compare
  • Fixed 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).
  • Simplified implementation of Channel.flatMap using toChannel function to work around Android 5.0 APK install SIGSEGV (see #205).

0.21.1

13 Jan 09:26
Compare
Choose a tag to compare
  • Improved performance of coroutine dispatching (DispatchTask instance is no longer allocated).
  • Fixed Job.cancel and CompletableDeferred.complete to 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.asDeferred immediately installs handlers to avoid "Unhandled promise rejection" warning.
    • Use window.postMessage instead of setTimeout for coroutines inside the browser to avoid timeout throttling (see #194).
    • Use custom queue in Window.awaitAnimationFrame to align all animations and reduce overhead.
    • Introduced Window.asCoroutineDispatcher() extension function.

JS

28 Dec 15:22
Compare
Choose a tag to compare
JS
  • Migrated to Kotlin 1.2.10.
  • Coroutines library for Kotlin/JS and multiplatform projects (see #33):
    • 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.
    • Full support for parent-child coroutine hierarchies.
    • Window.awaitAnimationFrame extension function.
    • Sample frontend Kotlin/JS application with coroutine-driven animations.
  • run is deprecated and renamed to withContext (see #134).
  • runBlocking and EventLoop implementations optimized (see #190).

0.20

04 Dec 11:58
Compare
Choose a tag to compare
  • Migrated to Kotlin 1.2.0.
  • Channels:
    • Sequence-like filter, map, etc extensions on ReceiveChannel are introduced (see #88 by @fvasco and #69 by @konrad-kaminski).
    • Introduced ReceiveChannel.cancel method.
    • All operators on ReceiveChannel fully consume the original channel (cancel it when they are done) using a helper consume extension.
    • Deprecated ActorJob and ProducerJob; actor now returns SendChannel and produce returns ReceiveChannel (see #127).
    • SendChannel.sendBlocking extension method (see #157 by @fvasco).
  • Parent-child relations between coroutines:
    • Introduced an optional parent job parameter for all coroutine builders so that code with an explict parent Job is more natural.
    • Added parent parameter to CompletableDeferred constructor.
    • Introduced Job.children property.
    • Job.cancelChildren is now an extension (member is deprecated and hidden).
    • Job.joinChildren extension is introduced.
    • Deprecated Job.attachChild as a error-prone API.
    • Fixed StackOverflow when waiting for a lot of completed children that did not remove their handlers from the parent.
  • Use java.util.ServiceLoader to find default instances of CoroutineExceptionHandler.
  • Android UI integration:
    • Use Thread.getUncaughtExceptionPreHandler to make sure that exceptions are logged before crash (see #148).
    • Introduce UI.awaitFrame for animation; added sample coroutine-based animation application for Android here.
    • Fixed delay(Long.MAX_VALUE) (see #161)
  • Added missing DefaultDispatcher on some reactive operators (see #174 by @fvasco)
  • Fixed actor and produce so 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.start on lazy coroutine with attached invokeOnCompletion handler.
  • A more gradual introduction to runBlocking and coroutines in the guide (see #166).

0.19.3

27 Oct 12:22
Compare
Choose a tag to compare
  • Fixed send/openSubscription race in ArrayBroadcastChannel. This race lead to stalled (hanged) send/receive invocations.
  • Project build has been migrated to Gradle.

0.19.2

21 Oct 15:24
Compare
Choose a tag to compare
  • Fixed ArrayBroadcastChannel receive of stale elements on openSubscription. Only elements that are sent after invocation of openSubscription are received now.
  • Added a default value for context parameter to rxFlowable (see PR #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.
    • UnexpectedCoroutineException is 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.
  • run uses cancelling state & propagates exceptions when cancelled (see #147):
    • When coroutine that was switched into a different dispatcher using run is 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.
  • No Job in newSingleThreadContext and newFixedThreadPoolContext anymore (see #149, #151):
    • This resolves the common issue of using 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.

0.19.1

07 Oct 20:36
Compare
Choose a tag to compare
  • 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/catch or other exception handlers.
  • Fixed a race in ArrayBroadcastChannel between send and openChannel invocations (see #138).
  • Fixed quite a rare race in runBlocking that resulted in AssertionError. Unfortunately, cannot write a reliable stress-test to reproduce it.
  • Updated Reactor support to leverage Bismuth release train (contributed by @sdeleuze, see PR #141)

0.19

29 Sep 20:39
Compare
Choose a tag to compare
  • This release is published to Maven Central.
  • 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.
    • When a context is explicitly specified, 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.
    • 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.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.
    • 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.
    • 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.
    • Introduced Deferred.getCompletionExceptionOrNull to get not-wrapped exception result of async task.
    • Updated docs for 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.
    • This opens road to moving channels into a separate module in future updates.
  • Renamed TimeoutException to TimeoutCancellationException (old name is deprecated).
  • Fixed various minor problems:
    • JavaFx toolkit is now initialized by JavaFx context (see #108).
    • Fixed lost ACC_STATIC on methods (see #116).
    • Fixed link to source code from documentation (see #129).
    • Fixed 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.

0.18

18 Aug 14:52
Compare
Choose a tag to compare
  • Kotlin 1.1.4 is required to use this version, which enables:
    • withLock and consumeEach functions are now inline suspend functions.
    • JobSupport class implementation is optimized (one fewer field).
  • TimeoutException is public (see #89).
  • Improvements to Mutex (courtesy of @fvasco):
    • Introduced holdsLock (see #92).
    • Improved documentation on Mutex fairness (see #90).
  • Fixed NPE when ArrayBroadcastChannel is 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 setCancellation with onDipose and
      updated to Aluminium-SR3 release (courtesy of @yxf07, see #96)
    • jdk8: Added adapters for java.time classes (courtesy of @fvasco, see #93)

0.17

24 Jul 14:20
Compare
Choose a tag to compare
  • CompletableDeferred is introduced as a set-once event-like communication primitive (see #70).
    • Coroutines guide uses it in a section on actors.
    • CompletableDeferred is an interface with private impl (courtesy of @fvasco, see #86).
    • It extends 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.
    • Internal select implementation is refactored to decouple it from JobSupport internal class and to optimize its state-machine.
    • Internal 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 contextin applications (like Android context, see #75).
  • BroadcastChannel.open is renamed to openSubscription (see #54).
  • Fixed StackOverflowError in a convoy of Mutex.unlock invokers with Unconfined dispatcher (see #80).
  • Fixed SecurityException when trying to use coroutines library with installed SecurityManager.
  • Fixed a bug in withTimeoutOrNull in case with nested timeouts when coroutine was cancelled before it was ever suspended.
  • Fixed a minor problem with 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).
  • All factory functions for various interfaces are implemented as top-level functions (affects Job, Channel, BroadcastChannel, Mutex, EventLoop, and CoroutineExceptionHandler). Previous approach of using operator invoke on their companion objects is deprecated.
  • Nicer-to-use debug toString implementations for coroutine dispatcher tasks and continuations.
  • A default dispatcher for 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).