func withUnsafeCurrentTask <T>(body: (UnsafeCurrentTask?) -> T) -> T
Overview 概要
To get an instance of Unsafe
for the current task, call the with
method.
Unsafe
のインスタンスを現在のタスクに対して取得するには、with
メソッドを呼び出してください。
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 with
method’s closure isn’t defined.
Only APIs on Unsafe
that are also part of Task
are safe to invoke from a task other than the task that this Unsafe
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.
その他のAPIを別のタスクから呼び出すことは、未定義挙動になります、このタスク上で動作しているプログラムの他の部分における不変式を壊します、そしてクラッシュまたはデータ損失に至らしめるかもしれません。
For information about the language-level concurrency model that Unsafe
is part of, see Concurrency in The Swift Programming Language.