hasActiveCancellationShield
Checks if this task is executing in a scope with a task cancellation shield activated by the withTaskCancellationShield(operation:) function.
Declaration
var hasActiveCancellationShield: Bool { get }Discussion
An active task cancellation shield prevents a task’s ability to observe if it was cancelled, i.e. the Task/isCancelled property will always return false when the task is executing with an active shield.
This property is primarily aimed at debugging and understanding cancellation behavior in complex call hierarchies, and should not be used in regular control flow.
Returns true when executing within a task that has an active cancellation shield.
Cancellation shields are not automatically inherited by child tasks; each child task must install its own shield if needed if it, independently, wanted to ignore cancellation during a specific scope.