We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I detected a strange behaviour in the follow code:
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.* import kotlinx.coroutines.delay import kotlinx.coroutines.withTimeoutOrNull import kotlinx.coroutines.yield suspend fun main() { repeat(100) { step -> println("step $step") val producer = GlobalScope.produce(capacity = 1024 * 1024) { repeat(1_000_000) { send(it) yield() } println("End producer") } val consumer = GlobalScope.actor<Int?>(capacity = Channel.CONFLATED) { while (true) receive() } producer.receive() delay(200) withTimeoutOrNull(100) { while (true) consumer.send(producer.receiveOrNull()) } producer.cancel() } }
it hangs with output
step 0 step 1 step 2 End producer
Kotlin 1.3.40 Coroutine 1.2.2 Java adoptopenjdk-12-jdk-hotspot
The text was updated successfully, but these errors were encountered:
As documented receiveOrNull "does not check for cancellation when it is not suspended"
receiveOrNull
Sorry, something went wrong.
No branches or pull requests
I detected a strange behaviour in the follow code:
it hangs with output
Kotlin 1.3.40
Coroutine 1.2.2
Java adoptopenjdk-12-jdk-hotspot
The text was updated successfully, but these errors were encountered: