From the Apple Docs for Task.init(priority:operation:)
:
Runs the given nonthrowing operation asynchronously as part of a new top-level task on behalf of the current actor.
I was wondering how the initialiser figures out the "current actor". Does anyone know what magic is happening inside the implementation of the initialiser to figure out what the current actor is when Task.init(priority:operation:)
is called? What if a function isn't running on any actor and you call Task.init(priority:operation:)
, how does it figure it out then?