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
gildor
08/04/2020, 10:20 AM
All methods include properties too, after all it also method on runtime
gildor
08/04/2020, 10:21 AM
Yes, it unknown who won this race for setting value, but it doesn't make method itself less thread safe
e
Erik
08/04/2020, 10:25 AM
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
gildor
08/04/2020, 10:33 AM
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