https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

Erik

05/03/2021, 3:15 PM
About this documentation: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow/emit.html If you call
MutableSharedFlow<Int>().emit(0)
(from a suspending function), then the
emit
call does not suspend. The documentation says that on buffer overflow the call should suspend. To me it seems that there is no buffer, so
emit(0)
causes a buffer overflow, so the
emit
call should suspend. Instead, it returns quickly! Am I misinterpreting the following?
suspending on buffer overflow
Or can the documentation be improved?
I understand the behaviour. That is not the issue. I just think that the documentation is easy to misunderstand.
By default, does
MutableSharedFlow()
have zero buffer, or no buffer? I mean that in the sense: Can the buffer of size zero overflow? Or is overflow impossible because there is no buffer in the first place? The latter seems to be the case judging from the actual behaviour. However, the
emit
docs don't mention that specifically.
But maybe that should be moved / copied to the
emit
docs
5 Views