I've long wanted to add to the proposal an @instantaneous also known as "can not actually suspend", specifically because those APIs.
It would have the effect of:
- allowing calls to those functions without
await - forbid the use of
awaitinside the function body of the instantaneous function.
i.e.:
@instantaneous func isCancelled() async -> Bool { ... }
if Task.isCancelled() { ... }
The wording I thought of this being instantaneous is because "can not suspend", but totally open to other names.
The same semantics would really help [Pitch] Task Local Values, reading a task local value never suspends, and having to await on them is pretty annoying:
let id = await Task.local(\.traceID) // meh
Perhaps this is the right proposal to include this new capability?