kotlinx.coroutines v0.17 Release Notes

    • ๐Ÿ‘€ CompletableDeferred is introduced as a set-once event-like communication primitive (see #70).
      • [Coroutines guide](docs/topics/coroutines-guide.md) 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 context in 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.
    • 0๏ธโƒฃ 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).