Structureswift 6.0.1_Concurrency
UnsafeCurrentTask
An unsafe reference to the current task.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
struct UnsafeCurrentTask
To get an instance of UnsafeCurrentTask
for the current task, call the withUnsafeCurrentTask(body:)
method. Don’t store an unsafe task reference for use outside that method’s closure. Storing an unsafe reference doesn’t affect the task’s actual life cycle, and the behavior of accessing an unsafe task reference outside of the withUnsafeCurrentTask(body:)
method’s closure isn’t defined.
Only APIs on UnsafeCurrentTask
that are also part of Task
are safe to invoke from a task other than the task that this UnsafeCurrentTask
instance refers to. Calling other APIs from another task is undefined behavior, breaks invariants in other parts of the program running on this task, and may lead to crashes or data loss.
For information about the language-level concurrency model that UnsafeCurrentTask
is part of, see Concurrency in The Swift Programming Language.
Citizens in _Concurrency
Conformances
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.
Type members
Instance members
var basePriority: TaskPriority
The current task’s base priority.
var isCancelled: Bool
A Boolean value that indicates whether the current task was canceled.
var priority: TaskPriority
The current task’s priority.
var unownedTaskExecutor: UnownedTaskExecutor?
The current
TaskExecutor
preference, if this task has one configured.func cancel(
) Cancel the current task.
func hash(into: inout Hasher
)
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.