Open mperucca opened 2 months ago
If you need cancelation, use Dispatcher.parallel
Ah, thanks. I was unknowingly reading the 3.5.3 scaladocs that my IDE had cached instead of the 3.5.4 ones. (Unfortunately Dispatcher.parallel
doesn't fit our use case as we're replacing a cancelable actor model. The private Dispatcher.sequentialCancelable
actually looks to have the behavior I was expecting though.)
Unfortunately
Dispatcher.parallel
doesn't fit our use case as we're replacing a cancelable actor model.
I see, can you say more about why it doesn't fit your usecase?
We only want one action happening at a time in the order that Dispatcher.unsafe*
is called, but we want any unstarted work to be cancelable. (We're migrating some code that had those semantics.)
We only want one action happening at a time in the order that
Dispatcher.unsafe*
is called
I see, are you calling Dispatcher.unsafe*
from a single thread or multiple threads? which variant of unsafe*
are you using?
but we want any unstarted work to be cancelable.
Ohhh I'm sorry I missed this subtlety. Actually I completely agree with you. This should be fixed. Canceling running work is challenging, but unqueued work should definitely be cancelable. I remember complaining about this too 🤔
Edit: aha, I think I raised this issue on Discord.
A queued task to a dispatcher cannot be canceled:
Perhaps this is explained somewhere, but it was surprising to me.