You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This clarifies a bit of the execution semantics. We updated most wording but this example was a bit misleading.
The diagrams and details explanations seem to be up to date.
Copy file name to clipboardExpand all lines: proposals/0417-task-executor-preference.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ func nonisolatedAsyncFunc() async -> Int {
124
124
}
125
125
```
126
126
127
-
or, for a specific scope using the `withTaskExecutorPreference` method:
127
+
or, for a specific scope using the `withTaskExecutorPreference` method. Notably, the task executor preference is in effect for the entire structured task hierarchy while running in a task or scope where a task executor preference is set. For example, the following snippet illustrates child tasks created inside of a `withTaskExecutorPreference`:
Notably, the task executor preference is in effect for the entire structured task hierarchy while running in a task or scope where a task executor preference is set. For example, the following snippet illustrates child tasks created inside of a `withTaskExecutorPreference`.
149
-
150
-
If a task with such executor preference encounters code which is `isolated` to some specific actor, it would adhere to that requirement and hop to it as expected:
148
+
If a task with such executor preference encounters code which is `isolated` to some specific actor, the isolation properties of the actor still are upheld, however, unless that actor has a custom executor configured, the source of the thread actually running the actor's functions will be from the preferred executor:
151
149
152
150
```swift
153
151
let capy: Capybara =Capybara()
154
152
actorCapybara { funceat() {} }
155
153
156
154
Task(executorPreference: executor) {
157
-
// starts on 'executor', however...
158
-
tryawait capy.eat() //still executes actor isolated code on the actor's executor, as expected
155
+
// starts on 'executor'
156
+
tryawait capy.eat() //execution is isolated to the 'capy' actor, however execution happens on the 'executor' TaskExecutor
159
157
}
160
158
```
161
159
160
+
In a way, one should think of the `SerialExecutor` of the actor and `TaskExecutor` both being tracked and providing different semantics.
161
+
The `SerialExecutor` guarntees mutual exclusion, and the `TaskExecutor` provides a source of threads.
0 commit comments