Skip to content

Commit fc544df

Browse files
committed
include special overload without priority
1 parent 081f107 commit fc544df

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

stdlib/public/Concurrency/TaskGroup+addTask.swift.gyb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ let __addTaskMustEnqueueJobOnCreate = true
106106
% 'operation: sending @escaping @isolated(any) () async throws -> ChildTaskResult'
107107
% ],
108108
% ),
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+
% ),
109124
% ]:
110125
%
111126
% for TYPE in TYPES:
@@ -121,7 +136,9 @@ let __addTaskMustEnqueueJobOnCreate = true
121136
% for METHOD_NAME in ADD_TASK_METHOD_VARIANT:
122137
%
123138
% IS_ADD_UNLESS_CANCELLED = METHOD_NAME == "addTaskUnlessCancelled"
139+
% IS_IMPL_UNAVAILABLE = any('Unavailable in task-to-thread' in av for av in ALL_AVAILABILITY)
124140
%
141+
% HAS_TASK_PRIORITY = any('priority:' in param for param in PARAMS)
125142
% HAS_TASK_NAME = any('name:' in param for param in PARAMS)
126143
% HAS_TASK_EXECUTOR = any('taskExecutor:' in param for param in PARAMS)
127144
%
@@ -156,7 +173,9 @@ extension ${TYPE} {
156173
% if HAS_TASK_EXECUTOR:
157174
/// - taskExecutor: The task executor that the child task should be started on and keep using.
158175
% end
176+
% if HAS_TASK_PRIORITY:
159177
/// - priority: The priority of the operation task.
178+
% end
160179
/// Omit this parameter or pass `.unspecified`
161180
/// to set the child task's priority to the priority of the group.
162181
/// - operation: The operation to execute as part of the task group.
@@ -169,6 +188,9 @@ extension ${TYPE} {
169188
public mutating func ${METHOD_NAME}(
170189
${",\n ".join(PARAMS)}
171190
) ${ARROW_RETURN_TYPE}{
191+
% if IS_IMPL_UNAVAILABLE:
192+
fatalError("Unavailable in task-to-thread concurrency model")
193+
% else: # !IS_IMPL_UNAVAILABLE
172194
% if IS_ADD_UNLESS_CANCELLED:
173195
let canAdd = _taskGroupAddPendingTask(group: _group, unconditionally: false)
174196

@@ -179,7 +201,7 @@ extension ${TYPE} {
179201
% end # IS_ADD_UNLESS_CANCELLED
180202

181203
let flags = taskCreateFlags(
182-
priority: priority,
204+
priority: ${'priority' if HAS_TASK_PRIORITY else 'nil'},
183205
isChildTask: true,
184206
copyTaskLocals: false,
185207
inheritContext: false,
@@ -252,6 +274,7 @@ extension ${TYPE} {
252274
% if IS_ADD_UNLESS_CANCELLED:
253275
return true // task successfully enqueued
254276
% end
277+
% end # !IS_IMPL_UNAVAILABLE
255278
}
256279

257280
}

0 commit comments

Comments
 (0)