anything you use for a return path there will invo...
# coroutines
a
anything you use for a return path there will involve some overhead, but you can read the source for Channel, they're fairly small/don't involve a lot of initialization overhead. You might find
CompletableDeferred
to be a better option for just a single value though
c
How would I use it? Based on the little example I wrote (or something completely different)
a
probably something like
Copy code
class Request<I, R>(val id: I) {
  val result: CompletableDeferred<R>()
}
val ch = Channel<Request<I, R>>()
with a send-request looking something like
Copy code
val req = Request(id)
ch.send(req)
val result = req.result.await()
and then the receiver does
req.result.complete(fetchedValue)
then all of the details managing the difference between requesting scope and cache-owner scope, cancellation of either
c
Thanks a lot, I'll look into that ^^