1. Is it safe to set the `value` of a `MutableSta...
# coroutines
e
1. Is it safe to set the
value
of a
MutableStateFlow
from multiple threads? I guess it is, but then it is unknown which of the setters set the last value (which is also the last one collected/got from
value
)? The
StateFlow
docs mention 'All methods of data flow are thread-safe and can be safely invoked from concurrent coroutines without external synchronization', but does this include the
value
setter and getter? Seems unlikely to me.
g
All methods include properties too, after all it also method on runtime
Yes, it unknown who won this race for setting value, but it doesn't make method itself less thread safe
e
I think I misinterpreted it then. So, what is meant is that
value
can be accessed from any thread and that it won't block the thread?
g
Yes, correct, it of course have some atomic primitives under the hood to linearize access to resource, but you have it with any thread safe code