Post

Replies

Boosts

Views

Activity

Comment on Task on MainActor does not run on the main thread, why?
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.
Jul ’22
Comment on Task on MainActor does not run on the main thread, why?
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?
Jul ’22