Comfy Cats Effect room. Ask questions. Rant about config file formats. Be nice!
If I use Async.async() inside of Resource.use(), I need to ensure myself that somehow the async operation is completed prior to the resource's release method is called
The use
method will not be called until (at least!) the callback inside of async
is run. Which is to say, you have control over it. Remember that async
doesn't mean "parallel", it just means non-blocking.
R
. Within the use
method I use Async.async() on R
(so the callback necessarily has to be called after the use
method). Assuming I am not altering ExecutionContexts or ContextShifts, is it possible for the release
method to be called prior to the callback finishing if I do not explicitly synchronize this?
use
, not after
start
, then you have a problem
async
, you will be safe
async
you see it
A => Unit
foo = bar(a)
becomes bar(a, foo => everythingElse)
bar(a: A, logicalReturn: A => Unit) = ...., logicalReturn(result)