What's the relationship between 'Task' and 'Actor'?

As we all know: Task.init creates an unstructured task that runs on the current actor, Task.detached creates an unstructured task that’s not part of the current actor.

I understand those differences when the context of creating a new unstructured task is on the main actor or any other actor, but what about it is on a concurrent executor other than a serial executor (which means an actor). In this situation, what's the difference between Task.init and Task.detached?

A Task does have a chance to NOT run on any actor, right?

1 Like

A Task does have a chance to NOT run on any actor, right?

Yes.

A good place to start with this stuff is WWDC 2022 Session 110351 Eliminate data races using Swift Concurrency, where Doug introduces the sailing on a sea of concurrency model.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like

Great stuff, thanks.