Is there a ReceiveChannel equivalent where every c...
# coroutines
c
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
BroadcastChannel
?
It looks like you require a complex actor.
You don't need a channel to achieve this, a simple suspending request method should do.
👍 1
suspend fun CacheManager.getObject(key: String): Any
should be enough.