Paulius Ruminas
12/13/2019, 1:15 PM@Test
fun example() = runBlocking {
val a = produce {
var i = 0
while (isActive) {
send(i++)
delay(100)
}
}
val b = a.broadcast(start = CoroutineStart.DEFAULT)
launch {
b.consumeEach {
println("A: $it")
}
}
b.close()
delay(1_000)
}
When I close b broadcast channel I get an exception:
Exception in thread "Test worker @coroutine#3" kotlinx.coroutines.channels.ClosedSendChannelException: Channel was closed (Coroutine boundary)
Is this the expected behavior?Dominaezzz
12/13/2019, 1:22 PMAntanas A.
12/13/2019, 1:23 PMPaulius Ruminas
12/13/2019, 1:27 PMval a = produce { while (isActive) send(1) }
val b = a.broadcast(start = CoroutineStart.DEFAULT)
b.close()
also throws an exceptionDominaezzz
12/13/2019, 1:31 PMval a = produce { while (isActive) send(1) }
a.close()
throw an exception? (Not on computer to check)Paulius Ruminas
12/13/2019, 1:35 PM