Resolved. Threads are blocked by filesystem operations.
Post
Replies
Boosts
Views
Activity
task2 is created as detached, so does NOT inherit the main actor async context, so it is correct not to run on the main thread. The example above was misleading.
THANKS! Yes, it seems that the devil must be in some detail. The swift doc says: "To create an unstructured task that runs on the current actor, call the Task.init(priority:operation:) initializer." And I am really curious, why task created in main() with inferred @MainActor (I have read that this static function has @MainActor inferred, when it is in the @main struct) does not all run on the main thread. I am puzzled.
Statement: "Swift makes no guarantee that the thread which executed the code before the await is the same thread which will pick up the continuation as well." Questions: Do I understand right that when the explicit async context is MainActor (Task closure is annotated by @MainActor), then it is guaranteed that the thread used for continuation (after await) will be the main thread? Is this guaranteed also for inherited MainActor async context?