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

Dias

02/08/2019, 3:31 PM
deferred is marked as volatile and I only set it, so it should be thread safe(?)
g

groostav

02/10/2019, 12:29 AM
You're asking that question from a very weak position. when using
kotlinx.coroutines
, its best to stay away from
volatile
,
java.util.concurrent
et al. I also suspect you're trying to use a deferred, which is fundamentally a one-shot value type, as the facade into a running process (which it is not).
So, I'm having a bit of trouble understanding your retry logic. Rather than using an abstraction that is a
var deferred
, which is having its value changed on restarts, how about you use a
Channel<String>
? a
ConflatedBroadcastChannel
might do what you want it to do.
d

Dias

02/11/2019, 9:28 AM
yeah your guess is right about using a deferred as facade of a process, it was an existing code that I was trying to improve, but looks like ConflatedBroadcastChannel is exactly what I need!
As far as I understood ConflatedBroadcastChannel keeps sending a value until it is replaced by another value?
11 Views