Is there a ReceiveChannel equivalent where every coroutine waiting to receive does receive, instead of a single random one?
The idea is that a single coroutine handles internally whether or not to download some objects from the internet (by delegating to a worker pool, then caching the result). Let's call it cacheManager.
The outside program can send an ID to cacheManager over its ReceiveChannel. You can then listen on cacheManager's SendChannel to get the object back, but if multiple people query at the same time, nothing ensures you'll get your request's results...
d
Dominaezzz
07/28/2019, 8:14 PM
BroadcastChannel
?
Dominaezzz
07/28/2019, 8:18 PM
It looks like you require a complex actor.
Dominaezzz
07/28/2019, 8:19 PM
You don't need a channel to achieve this, a simple suspending request method should do.
👍 1
Dominaezzz
07/28/2019, 8:20 PM
suspend fun CacheManager.getObject(key: String): Any