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

kevin.cianfarini

03/12/2021, 2:34 PM
Is setting the value on a MutableStateFlow thread safe?
yes black 3
a

Albert Chang

03/12/2021, 2:47 PM
It's documented.
All methods of state flow are thread-safe and can be safely invoked from concurrent coroutines without external synchronization.
k

kevin.cianfarini

03/12/2021, 3:24 PM
That’s just
StateFlow
. I was wondering if doing
myMutableStateFlow.value = foo
is thread safe
a

Albert Chang

03/12/2021, 3:54 PM
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-state-flow/value.html
This property is thread-safe and can be safely updated from concurrent coroutines without external synchronization.
k

kevin.cianfarini

03/12/2021, 4:02 PM
thanks. Big off. 🤦‍♂️
200 Views