Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with parent project #3

Merged
merged 166 commits into from
Nov 3, 2020
Merged

Conversation

circusmagnus
Copy link
Owner

No description provided.

elizarov and others added 30 commits March 18, 2020 12:10
The representation of not selected state is changed from _state === this to
_state === NOT_SELECTED (a special marker).
…1880)

During the change of the publication validator, a bug was
introduced that led to MavenPublicationValidator being run not on
the artifacts from the local Maven repository but on classfiles
from the corresponding subproject. This is a problem because this
test is for the behavior of the atomicfu plugin, which could in
theory produce nice classfiles in one place but wrong ones in the
other, and the only important thing to test is whether the
published classfiles are good.

Now, this is fixed.
* Fix DefaultExecutor not being able to exit.
* Also adds the performance optimization. See the discussion on the PR.
* Add a stress test for the DefaultExecutor worker shutting down.
* Make `testDelayChannelBackpressure2` not fail:

This test could in theory already fail on the second
`checkNotEmpty`: after the first `checkNotEmpty` has passed,
first, the ticker channel awakens to produce a new element, and
then the main thread awakens to check if it's there. However, if
the ticker channel is sufficiently slowed down, it may not produce
the element in time for the main thread to find it.

After introducing the change that allows the worker thread in
`DefaultExecutor` to shut down, the initial delay of 2500 ms is
sufficient for the worker to shut down (which, by default, happens
after 1000 ms of inactivity), and then the aforementioned race
condition worsens: additional time is required to launch a new
worker thread and it's much easier to miss the deadline.

Now, the delays are much shorter, meaning that the worker thread is
never inactive long enough to shut down.

Fixes #856
…1885)

When ArrayBroadcastChannel was closed it was still retaining a reference to its subscription (even if that subscription was cancelled) while, in fact, either closing a broadcast channel or cancelling subscription should remove the reference.

This is no problem with ConflatedBroadcastChannel, but it is added to the test for completeness.
* Update CoroutineScope docs
* Fixed scope examples in guides, added notes on first-party support in Android.
* Simplified scopes section in UI guide since it is mostly irrelevant.

Fixes #1581
* Integration with BlockHound
* Improve build configuration of integration tests
* publication-validator is renamed to integration-testing;
* Add an integration test for coroutine debugger java agent
* Use JNA-based attach mechanism for dynamic attach

Fixes #1821 
Fixes #1060

Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
* Introduce Flow.onEmpty operator

Fixes #1890
* Make the list of segments more abstract, so that it can be used for other synchronization and communication primitives

Co-authored-by: Roman Elizarov <elizarov@gmail.com>
* Further clarifications and better style for exception handling
* Consistent terminology on "uncaught exceptions".
* Clarified special relations of exception handling with supervision.
* Clearer text in CoroutineExceptionHandler examples.
* Minor stylistic corrections.

Fixes #1746
Fixes #871

Co-Authored-By: EdwarDDay <4127904+EdwarDDay@users.noreply.github.com>
* Make semaphore implementation linearizable (ignoring extra suspensions)
* Make mutex implementation linearizable (ignoring extra suspensions)
* Add linearizability tests for mutex and semaphore
* Fix `SegmentQueueLCStressTest`

Fixes #1737

Co-authored-by: Roman Elizarov <elizarov@gmail.com>
This is debug agent machinery rework in order to prepare for IDEA integration

    * Extract internal DebugProbesImpl to kotlinx-coroutines-core
    * Introduce AgentPremain that works without ByteBuddy to kotlinx-coroutines-core, so it now can be used as Java agent and all debug info can be extracted via reflection or JDWP
    * Reflective lookup of ByteBuddy attach to resolve cyclic dependency between core and debug modules
    * Reduce public API surface, introduce JDWP-specific API
    * Introduce a mechanism to produce a DebugProbesKt.bin and verify them against the golden value
Fixes #1883

Co-authored-by: Zac Sweers <zsweers@slack-corp.com>
…1732)

Flow.onCompletion now reports all failures and cancellation in its cause just like invokeOnCompletion. A null cause is reported if and only if flow had completed successfully (no failure, no cancellation). Emission of additional elements after the end of the flow is only possible from inside of onCompletion block in case of successful completion.

Also fixed a bug where onCompletion implementation was trying to add exception to its own list of suppressed exceptions, which is not allowed.

Fixes #1693
… integrate with APIs that may block the current thread, but react on cancellation (#1680)

Fixes #1671
* Remove experimental annotation from Flow terminal and Channel operators
* Remove experimental annotation from Flow count* and reduce* operators
* Remove experimental annotation from Flow operations, including buffer and flowOn
* Remove experimental annotation from combine and zip
elizarov and others added 29 commits October 12, 2020 19:09
…1937)

This is a problematic for Android when Main dispatcher is cancelled on destroyed activity.
Atomic nature of channels is designed to prevent loss of elements,
which is really not an issue for a typical application, but creates problem when used with channels.

* Internal suspendAtomicCancellableCoroutine -> suspendCancellableCoroutine
* Internal suspendAtomicCancellableCoroutineReusable -> suspendCancellableCoroutineReusable
* Remove atomic cancellation from docs
* Ensures that flowOn does not resume downstream after cancellation.
* MODE_ATOMIC_DEFAULT renamed into MODE_ATOMIC
* Introduced MODE_CANCELLABLE_REUSABLE to track suspendCancellableCoroutineReusable
* Better documentation for MODE_XXX constants.
* Added stress test for proper handling of MODE_CANCELLABLE_REUSABLE
  and fixed test for #1123 bug with job.join (working in MODE_CANCELLABLE) that was not
  properly failing in the absence of the proper code in CancellableContinuationImpl.getResult
* Added test for Flow.combine that should be fixed
* Support extended invokeOnCancellation contract
* Introduced internal tryResumeAtomic
* Channel onUnderliveredElement is introduced as a replacement.

Fixes #1265
Fixes #1813
Fixes #1915
Fixes #1936

Co-authored-by: Louis CAD <louis.cognault@gmail.com>
Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
* Introduce SharedFlow and sharing operators

Summary of changes:
* SharedFlow, MutableSharedFlow and its constructor.
* StateFlow implements SharedFlow.
* SharedFlow.onSubscription operator, clarified docs in other onXxx operators.
* BufferOverflow strategy in kotlinx.coroutines.channels package.
* shareIn and stateIn operators and SharingStarted strategies for them.
* SharedFlow.flowOn error lint (up from StateFlow).
* Precise cancellable() operator fusion.
* Precise distinctUntilChanged() operator fusion.
* StateFlow.compareAndSet function.
* asStateFlow and asSharedFlow read-only view functions.
* Consistently clarified docs on cold vs hot flows.
* Future deprecation notice for BroadcastChannel, ConflatedBroadcastChannel, broadcast, and broadcastIn.
* Channel(...) constructor function has onBufferOverflow parameter.
* buffer(...) operator has onBufferOverflow parameter.
* shareIn/stateIn buffer and overflow strategy are configured via upstream buffer operators.
* shareIn/stateIn fuse with upstream flowOn for more efficient execution.
* conflate() is implemented as buffer(onBufferOverflow=KEEP_LATEST), non-suspending strategies are reasonably supported with 0 and default capacities.
* Added reactive operator migration hints.
* WhileSubscribed with kotlin.time.Duration params

Fixes #2034
Fixes #2047

Co-authored-by: Ibraheem Zaman <1zaman@users.noreply.github.com>
Co-authored-by: Thomas Vos <thomasjsvos@gmail.com>
Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Otherwise, we have to keep our coroutine debugger disabled all the time: it attempts to read system property and fails on start
#2315)

Cleanup lazy coroutines that have been cancelled but not yet garbage collected

Fixes #2294
…and access properties in a safe manner from agent premain instead (#2311)
* Rework Flow.zip operator: improve its performance by 40%, collect one of the upstreams in the same coroutine as emitter

* Rework Flow.combine
    * Get rid of two code paths
    * Get rid of accidental O(N^2) where N is the number of flows that caused #2296
    * Get rid of select that hits performance hard, improving performance by 50% in the pessimistic case
    * Get rid of crossinlines in API and implementation to fix Android issues
    * Make combine fairer and its results less surprising in sequential scenarios

* Improve stacktrace recovery and stackwalking for SafeCollector, flowOn and zip operators
* Update JMH

Fixes #1743
Fixes #1683
Fixes #2296
Co-authored-by: lalitbehera <lalitkumar.b@landmarkgroup.in>
)

* Do not use invokeSafely in onCompletion

Co-authored-by: Roman Elizarov <elizarov@gmail.com>
Fixes #2104
Fixes #2299

Co-authored-by: Louis CAD <louis.cognault@gmail.com>
…#2325)

Problematic scenario:
* Emitter suspends because there is a slow subscriber
* Fast subscriber collects all the values and suspend
* Slow subscriber resumes, collects value, causes emitter to be resume
* Fast subscribers must be resumed in this case, too

Fixes #2320
Co-authored-by: Miguel Kano <miguel.g.kano@gmail.com>
Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
* Gracefully increase deprecation level on Channel operators instead of removing them, a warning was not strict enough
* Remove hidden onCompletion from -M release
* Promote StateFlow and SharedFlow to stable API
* Lift out experimentality where it is applicable

    * CoroutineDispatcher.invoke
    * ReceiveChannel.consume and ReceiveChannel.consumeEach
    * Flow core operators: onStart, onCompletion, onEmpty
    * CompletableDeferred.completeWith
    * awaitCancellation
    * Add experimentality notes where applicable
@circusmagnus circusmagnus merged commit ccb76c8 into circusmagnus:master Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet