ursus
05/02/2021, 11:55 PMstream
.flatMapLatest {
flow {
if (!blockingGetWritten()) {
someSuspendFunction()
blockingSetWritten(true)
}
}
}
when upstream emits during the inner if statement, lets say just after someSuspendFunction
but the blockingSetWritten
has started executing, so it will finish regardless, because its blocking
that however means, the new upstream emit might see blockingGetWritten
still as false
thefore i neet to wrap the if statement in a Mutex
right?
(or will the upstream somehow wait till blockingSetWritten
completes -- I presume not)
// Oh, If I actually cause upstream to change during the blockingSetWritten
the flatMapLatest does not emit right away, it waits for the blocking function to complete, is this a coincidence or by design? I'd not expect that, since its on IO dispatcher anyways