In concurrency, Task.isCancelled can never change until *after* an “await,” right? So if I have an async function that does a few things before it’s first “await” there’s no way the task could have been canceled until at least *after* the first “await”, right?

Actually I suppose if the task was cancelled before my async function was even called, but the caller didn’t check for Task.isCancelled, then maybe it *could* be cancelled from the very beginning. 🤔

Follow

Specifically, though, I *think* Task.isCancelled can’t become true except at await points… right?

· · Web · 1 · 0 · 0
@bigzaphod I think it can be cancelled at any point, but it's not really worth checking unless after a decent chunk of time has elapsed (due to await, or even just a lot of synchronous compute-heavy work)
Sign in to participate in the conversation
Mastodon

The original server operated by the Mastodon gGmbH non-profit