I am try to solve an problem that I think is suite...
# coroutines
j
I am try to solve an problem that I think is suited for
channels
, but I’m not positive. I have an object that may be ready after it main consumer comes looking for it. I want to have the consumer wait until it is ready (unless of course the object is ready first, in which case it just takes it). So far so good. The trick is that the object may be replaced by a new object occasionally and I would like the consumer to take whatever is the freshest. I believe
channels
are FIFO, and that is where I am running into trouble. Also, if a second consumer comes along, they should also get the freshest object, even if someone else is using it as well. Does that make sense? Am I overthinking this? In C#, we had
TaskCompletionSources
would were very good for this exact task, but I’m not sure if there is a Kotlin coroutine equivalent.