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
CLOVIS
07/28/2019, 7:21 PM
How would I use it? Based on the little example I wrote (or something completely different)
a
Adam Powell
07/28/2019, 7:29 PM
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)
Adam Powell
07/28/2019, 7:32 PM
then all of the details managing the difference between requesting scope and cache-owner scope, cancellation of either