@@ -106,6 +106,21 @@ let __addTaskMustEnqueueJobOnCreate = true
106
106
% 'operation: sending @escaping @isolated(any) () async throws -> ChildTaskResult'
107
107
% ],
108
108
% ),
109
+ % (
110
+ % 'SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY',
111
+ % [
112
+ % 'TaskGroup',
113
+ % 'ThrowingTaskGroup',
114
+ % ],
115
+ % [
116
+ % '@available(SwiftStdlib 5.7, *)',
117
+ % '// version for task to thread model, without priority parameter',
118
+ % ],
119
+ % ['addTask', 'addTaskUnlessCancelled'],
120
+ % [
121
+ % 'operation: sending @escaping @isolated(any) () async throws -> ChildTaskResult'
122
+ % ],
123
+ % ),
109
124
% ]:
110
125
%
111
126
% for TYPE in TYPES:
@@ -121,7 +136,9 @@ let __addTaskMustEnqueueJobOnCreate = true
121
136
% for METHOD_NAME in ADD_TASK_METHOD_VARIANT:
122
137
%
123
138
% IS_ADD_UNLESS_CANCELLED = METHOD_NAME == "addTaskUnlessCancelled"
139
+ % IS_IMPL_UNAVAILABLE = any('Unavailable in task-to-thread' in av for av in ALL_AVAILABILITY)
124
140
%
141
+ % HAS_TASK_PRIORITY = any('priority:' in param for param in PARAMS)
125
142
% HAS_TASK_NAME = any('name:' in param for param in PARAMS)
126
143
% HAS_TASK_EXECUTOR = any('taskExecutor:' in param for param in PARAMS)
127
144
%
@@ -156,7 +173,9 @@ extension ${TYPE} {
156
173
% if HAS_TASK_EXECUTOR:
157
174
/// - taskExecutor: The task executor that the child task should be started on and keep using.
158
175
% end
176
+ % if HAS_TASK_PRIORITY:
159
177
/// - priority: The priority of the operation task.
178
+ % end
160
179
/// Omit this parameter or pass `.unspecified`
161
180
/// to set the child task's priority to the priority of the group.
162
181
/// - operation: The operation to execute as part of the task group.
@@ -169,6 +188,9 @@ extension ${TYPE} {
169
188
public mutating func ${METHOD_NAME}(
170
189
${",\n ".join(PARAMS)}
171
190
) ${ARROW_RETURN_TYPE}{
191
+ % if IS_IMPL_UNAVAILABLE:
192
+ fatalError("Unavailable in task-to-thread concurrency model")
193
+ % else: # !IS_IMPL_UNAVAILABLE
172
194
% if IS_ADD_UNLESS_CANCELLED:
173
195
let canAdd = _taskGroupAddPendingTask(group: _group, unconditionally: false)
174
196
@@ -179,7 +201,7 @@ extension ${TYPE} {
179
201
% end # IS_ADD_UNLESS_CANCELLED
180
202
181
203
let flags = taskCreateFlags(
182
- priority: priority,
204
+ priority: ${' priority' if HAS_TASK_PRIORITY else 'nil'} ,
183
205
isChildTask: true,
184
206
copyTaskLocals: false,
185
207
inheritContext: false,
@@ -252,6 +274,7 @@ extension ${TYPE} {
252
274
% if IS_ADD_UNLESS_CANCELLED:
253
275
return true // task successfully enqueued
254
276
% end
277
+ % end # !IS_IMPL_UNAVAILABLE
255
278
}
256
279
257
280
}
0 commit comments