aboutsummaryrefslogtreecommitdiffstats
path: root/kotlinx-coroutines-core/jvm
Commit message (Collapse)AuthorAgeFilesLines
* Revert^2 "Merge tag '1.4.3'"Aurimas Liutikas2021-05-1776-257/+689
| | | | | | 7b14046dc70bd6c00de7b2dc56a93c3d03925e86 Change-Id: I848f30a15f99f2a06e1a3c3bcf15881c9d9db0f1
* Revert "Merge tag '1.4.3'"android-s-beta-2android-s-beta-1Aurimas Liutikas2021-05-1276-689/+257
| | | | | | | | This reverts commit b4c8c9ba7d6064a126ae0cb67f4f271f4e4a885a. Reason for revert: b/187908823 Change-Id: I171329d6b9b8c3fb2087097d4ed934f7384ffebf
* Merge branch 'master' into developVsevolod Tolstopyatov2021-03-0210-10/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # README.md # coroutines-guide.md # docs/basics.md # docs/cfg/buildprofiles.xml # docs/kc.tree # docs/topics/coroutines-basic-jvm.md # docs/topics/coroutines-guide.md # docs/topics/debugging.md # docs/topics/knit.properties
| * update: rename basics.md to coroutines-basics.md (#2538)koshachy2021-02-1910-10/+10
| | | | | | | | * update: rename basics.md to coroutines-basics.md * update: add fix for correct page indexing
* | Rename TimeSource to SchedulerTimeSource due to KT-42625 (#2537)Vsevolod Tolstopyatov2021-02-162-5/+6
| |
* | Properly nest ThreadContextElement (#2517)Vsevolod Tolstopyatov2021-02-082-18/+81
| | | | | | | | | | | | * Restore the context in the reverse order of update, so they are properly nested into each other Fixes #2195
* | Update Kotlin to 1.4.30 (#2523)Vsevolod Tolstopyatov2021-02-041-0/+0
| |
* | Update copyright year (#2520)Vsevolod Tolstopyatov2021-02-0445-47/+47
| |
* | Restore thread context elements when directly resuming to parent (#1577)Roman Elizarov2021-02-014-6/+302
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix solves the problem of restoring thread-context when returning to another context in an undispatched way. It impacts suspend/resume performance of coroutines that use ThreadContextElement and undispatched coroutines. The kotlinx.coroutines code poisons the context with special 'UndispatchedMarker' element and linear lookup is performed only when the marker is present. The code also contains a description of an alternative approach in order to save a linear lookup in complex coroutines hierarchies. Fast-path of coroutine resumption is slowed down by a single context lookup. Fixes #985 Co-authored-by: Roman Elizarov <elizarov@gmail.com> Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
* | Make internal functions public in already internal CoroutineScheduler in ↵Vsevolod Tolstopyatov2021-01-211-7/+7
| | | | | | | | order to get prettier stacktraces without "$kotlinx_coroutines_core" in function names (#2487)
* | Preserve a frame with source code location when sanitizing traces (#2452)dkhalanskyjb2021-01-181-20/+27
| | | | | | Fixes https://github.com/Kotlin/kotlinx.coroutines/issues/1437
* | Using the same logic as packNanos in the code below (#2463)Vyacheslav2020-12-281-1/+1
| | | | | | Signed-off-by: slavon <v.badalyan@open-bs.ru>
* | Fix incorrect ProGuard rules that allowed shrinking volatile felds (#2453)dkhalanskyjb2020-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | * Fix incorrect ProGuard rules that allowed shrinking volatile felds Fixes #1564 * Modify ProGuard rules to only affect `kotlinx.coroutines.**` Before, some rules were applied to a wide range of libraries for no good reason. Now, they are limited to this library.
* | Cleanup core module after update to Kotlin 1.4 (#2440)Vsevolod Tolstopyatov2020-12-1111-13/+9
| | | | | | | | | | | | * Remove explicit API mode suppressions * Use list build in ReceiveChannel.toList to prevent casting to mutable list * Migrate to maxByOrNull * Remove redundant nullabilities
* | Remove requirement that job of the pre-created JobCancelNode have to … (#2427)Vsevolod Tolstopyatov2020-12-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | Remove the requirement that the job of the pre-created JobCancelNode have to be equal to the outer job Job is supposed to be "sealed" interface, but we also have non-sealed Deferred that can be successfully implemented via delegation and such delegation may break code (if assertions are enabled!) in very subtle ways. This assertion is our internal invariant that we're preserving anyway, so it's worth to lift it to simplify the life of our users in the future Fixes #2423 Co-authored-by: Roman Elizarov <elizarov@gmail.com>
* | Update to Kotlin 1.4.20 (#2424)Vsevolod Tolstopyatov2020-12-021-0/+0
| | | | | | | | | | | | * Rework publish-mpp-root-module-in-platform.gradle * Update stackwalking tests Co-authored-by: anastasiia.spaseeva <anastasiia.spaseeva@jetbrains.com>
* | Add the model checking mode in Lincheck tests (#2326)Nikita Koval2020-11-2810-117/+142
|/ | | | | * Add the model checking mode to Lincheck tests and use a newer and faster version of it Co-authored-by: Roman Elizarov <elizarov@gmail.com>
* Add build parameter to build coroutines with JVM IR compiler (#2389)Alexander Likhachev2020-11-181-3/+3
| | | | | | | | * Add build parameters to enable JVM IR and disable native targets * enable_jvm_ir enables JVM IR compiler * disable_native_targets disables native targets in train builds * enable_jvm_ir_api_check enables JVM IR API check (works only if enable_jvm_ir is set) * Fix "Return type must be specified in explicit API mode" in 1.4.20
* Unlock Mutex and release Semaphore during cancellation on a fast branch of ↵Vsevolod Tolstopyatov2020-11-182-2/+36
| | | | | | | | slow-path in Mutex/Semaphore (#2396) Fixes #2390 Co-authored-by: Gareth Pearce <Tilps@users.noreply.github.com>
* Simplify JobNode.toString to reduce code and avoid potential StackOverflow ↵Roman Elizarov2020-11-141-1/+0
| | | | | (#2377) Fixes #2371
* Prevent potential re-park when the unparking thread is too slow (#2381)Vsevolod Tolstopyatov2020-11-132-2/+14
|
* SharedFlow: Fix scenario with concurrent emitters and cancellation of ↵Roman Elizarov2020-11-031-0/+87
| | | | | | | | subscriber (#2359) * Added a specific test for a problematic scenario. * Added stress test with concurrent emitters and subscribers that come and go. Fixes #2356
* Update experimental declarations (#2316)Vsevolod Tolstopyatov2020-10-262-909/+3
| | | | | | | | | | | | | | | * 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
* Add debounce with selector and kotlin.time (#2336)Roman Elizarov2020-10-265-12/+88
| | | | Co-authored-by: Miguel Kano <miguel.g.kano@gmail.com> Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
* Release intercepted SafeCollector when onCompletion block is done (#2323)Vsevolod Tolstopyatov2020-10-222-1/+45
| | | | | * Do not use invokeSafely in onCompletion Co-authored-by: Roman Elizarov <elizarov@gmail.com>
* Combine and zip rework (#2308)Vsevolod Tolstopyatov2020-10-202-1/+14
| | | | | | | | | | | | | | | | | * 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
* Introduce CoroutineContext.job extension (#2312)Vsevolod Tolstopyatov2020-10-192-3/+2
| | | Fixes #2159
* Remove workaround for KT-42671 that triggers test failures from IDEA and ↵Vsevolod Tolstopyatov2020-10-191-2/+2
| | | | access properties in a safe manner from agent premain instead (#2311)
* Cleanup lazy coroutines that have been cancelled but not yet garbage … (#2315)Vsevolod Tolstopyatov2020-10-191-1/+22
| | | | | Cleanup lazy coroutines that have been cancelled but not yet garbage collected Fixes #2294
* Fixed RejectedExecutionTest on JDK1.6Roman Elizarov2020-10-131-0/+3
|
* Introduce SharedFlow and sharing operators (#2069)Roman Elizarov2020-10-133-1/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Breaking: Get rid of atomic cancellation and provide a replacement (#1937)Roman Elizarov2020-10-1215-217/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Cancel current Job on RejectedExecutionException (#2012)Roman Elizarov2020-10-0910-31/+252
| | | | | When the Executor that was used with Executor.asCoroutineDispatcher() extension rejects the submitted task, it means that it had reached its capacity and so the executing current Job should be canceled to terminate it as soon as possible. This way RejectedExecutionException works as a rate-limiter just like it serves this purpose in executor-based Java code. Fixes #2003
* Added docs on withTimeout asynchrony and its use with resources (#2252)Roman Elizarov2020-10-083-0/+74
| | | | | This is a tricky gotcha that needs additional explanation. There are two examples added, one showing the bad code and explaining why it does not work, and the other showing the correct way to write it. Fixes #2233
* Update Flow.sample KDoc example timings, add tests (#2259)Roman Elizarov2020-10-0815-2/+140
| | | | | | * All Flow.debounce/sample KDoc example code snippets are automatically tested with Knit. * Flow.sample timings are made larger, so that they produce an expected output when run under the real time, too. Fixes #2243
* Clarify documentation for IO dispatcher (#2286)Vsevolod Tolstopyatov2020-10-081-1/+5
| | | Fixes #2272
* Fix wrong Proguard rules (#2273)dkhalanskyjb2020-10-011-0/+6
| | | | Fixes #2046 Fixes #2266
* Cherry-picks from native-mt branch to reduce maintenance burden (#2204)Vsevolod Tolstopyatov2020-08-241-1/+1
| | | | * Immediate dispatcher on JS, test added * Style fixes
* Fix sporadic ConcurrentWeakMapTest failures (#2187)Vsevolod Tolstopyatov2020-08-201-6/+6
|
* Update api dump for 1.4.0 compilerStanislav Erokhin2020-08-131-0/+0
|
* Fix hanging RunInterruptibleStressTest on Windows with JDK 1.6 (#2145)Roman Elizarov2020-07-171-11/+13
| | | | | The test is improved so that it fails, not hangs, on a failure. However, it will not pass on Windows + JDK 1.6 due to a bug in JDK (which can be easily confirmed with this modification to a test), so it excluded when running on JDK 1.6. Fixes #2144
* Coroutines debugger should keep weak references to running coroutines (#2129)Roman Elizarov2020-07-1611-139/+703
| | | | | | | | | | | | It should not prevent garbage-collection of coroutines that were otherwise lost, which included the following practically-useful cases: * Synchronous coroutines (iterator/sequence). * Lazy coroutines that were not started. * Abandoned coroutines that suspend forever without strong references to them in GlobalScope. Two kinds of tests cover this functionality: * A test via FieldWalker ensures that debugger impl does not keep a strong reference. This tests works fast and provides good diagnostics if anything goes wrong, but it is fragile, as futures changes to debugger my introduce static references to running coroutines elsewhere. * A stress-test that ensures that no OOM indeed happens when you run a lot of such lost coroutines. Longer-running, more stable to code change, but fragile in a difference sense as it may accidentally start passing in the future if lots of memory get allocated for tests. Fixes #2117
* Increase timeout in the example to make sure it fails with threads (#2141)Roman Elizarov2020-07-161-1/+1
| | | Fixes #2135
* Consistent toString for MainCoroutineDispatcher implementations (#2131)Roman Elizarov2020-07-162-1/+19
| | | | So that is shows as "Dispatchers.Main" and "Dispatchers.Main.immediate". Also remove hardcoded "Main" name in places of code where it is not needed anymore.
* Merge remote-tracking branch 'origin/master' into developRoman Elizarov2020-07-1623-48/+48
|\
| * Rename 'foo' function to 'simple' in flow docs (#2078)Roman Elizarov2020-07-1623-48/+48
| | | | | | The name 'foo' might be hard to get for novice developers. It is really hard to find a "meaningful" name for all examples in the docs, so this is simply a consistent solution. The alternative is to something like "simpleFlow", but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style.
* | Merge remote-tracking branch 'origin/master' into developRoman Elizarov2020-07-034-23/+23
|\|
| * Fix typos in docs (#2098)Yanis Batura2020-07-034-23/+23
| | | | | | | | Co-authored-by: Louis CAD <louis.cognault@gmail.com>
* | Merge remote-tracking branch 'origin/master' into developRoman Elizarov2020-07-031-1/+1
|\|
| * Fixed val counter AtomicInteger in shared state example (#2063)Roman Elizarov2020-05-271-1/+1
| | | | | | Fixes #2062