kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Library support for Kotlin coroutines
Reported by @joffrey-bion in the Kotlinlang Slack. Currently, the coroutines guide uses `runBlocking` freely to explain the concept of coroutines. However, in practice, `runBlocking` does not have such a prominent...
`withContext` ingnores cancellation from `withTimeout` when the dispatcher cannot execute the body
**Describe the bug** The following code hangs, while I expected it to output Timeout. When I uncomment the commented code, it works as I expected, so `withContext` handles timeouts differently....
In `kotlinx.coroutines`, we have two types of functions called `await()`: * Multiple consumers can call `await()` independently: this is the case for [JS Promise](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/await.html), [Deferred](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/await.html), the [reactive integrations](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/await.html), and [`com.google.android.gms.tasks.Task`...
Update outdated full-queue check logic of `LockFreeTaskQueueCore`. No more need to have 2 margin elements; one is sufficient. Tested in `LockFreeTaskQueueStressTest` and `LockFreeTaskQueueTest` See also #4205
In this case, `StartLazily` uses `flow`, but since it simply collects `subscriptionCount` and processes it, there is no need to use SafeFlow and consume additional resources for context checks. ```...
**Describe the bug** Using: kotlin = "2.1.20" coroutine = "1.10.2" In my test class if I use `runTest` I get the error: ``` java.lang.ClassCastException: class kotlinx.coroutines.test.TestCoroutineScheduler$timeSource$1 cannot be cast to...
#### Basic idea ```kotlin interface CoroutinePausing : CoroutineContext.Element { val isPaused: StateFlow override val key: CoroutineContext.Key get() = Key companion object Key : CoroutineContext.Key } ``` - Downstream _may_ provide...
This issue was discovered analytically, by reading the source code. No one reported it yet. ```kotlin val threadLocal = ThreadLocal.withInitial { "default" } @Test fun testFlowOnThreadContext() = runBlocking { val...