1313import Swift
1414@_implementationOnly import SwiftConcurrencyInternalShims
1515
16- // ==== Task.startSynchronously ------------------------------------------------
16+ // ==== Task.immediate --------- ------------------------------------------------
1717
1818% METHOD_VARIANTS = [
1919% 'THROWING',
@@ -32,6 +32,17 @@ import Swift
3232@available(SwiftStdlib 6.2, *)
3333extension Task where Failure == ${FAILURE_TYPE} {
3434
35+ @available(SwiftStdlib 6.2, *)
36+ @available(*, deprecated, renamed: "immediate")
37+ @discardableResult
38+ public static func startSynchronously(
39+ name: String? = nil,
40+ priority: TaskPriority? = nil,
41+ @_implicitSelfCapture _ operation: __owned @isolated(any) @escaping () async throws -> Success
42+ ) -> Task<Success, ${FAILURE_TYPE}> {
43+ immediate(name: name, priority: priority, operation)
44+ }
45+
3546 /// Create and immediately start running a new task in the context of the calling thread/task.
3647 ///
3748 /// This function _starts_ the created task on the calling context.
@@ -56,11 +67,11 @@ extension Task where Failure == ${FAILURE_TYPE} {
5667 /// - Returns: A reference to the unstructured task which may be awaited on.
5768 @available(SwiftStdlib 6.2, *)
5869 @discardableResult
59- public static func startSynchronously (
70+ public static func immediate (
6071 name: String? = nil,
6172 priority: TaskPriority? = nil,
6273 % # NOTE: This closure cannot be 'sending' because we'll trigger ' pattern that the region based isolation checker does not understand how to check'
63- % # In this case: `func syncOnMyGlobalActor() { Task.startSynchronously { @MyGlobalActor in } }`
74+ % # In this case: `func syncOnMyGlobalActor() { Task.immediate { @MyGlobalActor in } }`
6475 @_implicitSelfCapture _ operation: __owned @isolated(any) @escaping () async throws -> Success
6576 ) -> Task<Success, ${FAILURE_TYPE}> {
6677
@@ -109,7 +120,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
109120 }
110121
111122 if canRunSynchronously {
112- _startTaskSynchronously (task!, targetExecutor: builtinSerialExecutor)
123+ _startTaskImmediately (task!, targetExecutor: builtinSerialExecutor)
113124 }
114125 return Task<Success, ${FAILURE_TYPE}>(task!)
115126 }
@@ -121,35 +132,35 @@ GROUP_AND_OP_INFO = [
121132 (
122133 'TaskGroup',
123134 [
124- 'startTaskSynchronously ',
125- 'startTaskSynchronouslyUnlessCancelled '
135+ 'addImmediateTask ',
136+ 'addImmediateTaskUnlessCancelled '
126137 ],
127138 '',
128139 'ChildTaskResult'
129140 ),
130141 (
131142 'ThrowingTaskGroup',
132143 [
133- 'startTaskSynchronously ',
134- 'startTaskSynchronouslyUnlessCancelled '
144+ 'addImmediateTask ',
145+ 'addImmediateTaskUnlessCancelled '
135146 ],
136147 'throws ',
137148 'ChildTaskResult'
138149 ),
139150 (
140151 'DiscardingTaskGroup',
141152 [
142- 'startTaskSynchronously ',
143- 'startTaskSynchronouslyUnlessCancelled '
153+ 'addImmediateTask ',
154+ 'addImmediateTaskUnlessCancelled '
144155 ],
145156 '',
146157 'Void'
147158 ),
148159 (
149160 'ThrowingDiscardingTaskGroup',
150161 [
151- 'startTaskSynchronously ',
152- 'startTaskSynchronouslyUnlessCancelled '
162+ 'addImmediateTask ',
163+ 'addImmediateTaskUnlessCancelled '
153164 ],
154165 'throws ',
155166 'Void'
@@ -204,7 +215,7 @@ extension ${GROUP_TYPE} {
204215 taskGroup: self._group,
205216 operation: operation
206217 )
207- _startTaskSynchronously (task, targetExecutor: builtinSerialExecutor)
218+ _startTaskImmediately (task, targetExecutor: builtinSerialExecutor)
208219 }
209220}
210221% end # METHOD_NAMES
@@ -264,5 +275,5 @@ extension Task where Failure == ${FAILURE_TYPE} {
264275@_silgen_name("swift_task_startOnMainActor")
265276internal func _startTaskOnMainActor(_ task: Builtin.NativeObject)
266277
267- @_silgen_name("swift_task_startSynchronously ")
268- internal func _startTaskSynchronously (_ task: Builtin.NativeObject, targetExecutor: Builtin.Executor?)
278+ @_silgen_name("swift_task_immediate ")
279+ internal func _startTaskImmediately (_ task: Builtin.NativeObject, targetExecutor: Builtin.Executor?)
0 commit comments