13
13
import Swift
14
14
@_implementationOnly import SwiftConcurrencyInternalShims
15
15
16
- // ==== Task.startSynchronously ------------------------------------------------
16
+ // ==== Task.immediate --------- ------------------------------------------------
17
17
18
18
% METHOD_VARIANTS = [
19
19
% 'THROWING',
@@ -32,6 +32,17 @@ import Swift
32
32
@available(SwiftStdlib 6.2, *)
33
33
extension Task where Failure == ${FAILURE_TYPE} {
34
34
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
+
35
46
/// Create and immediately start running a new task in the context of the calling thread/task.
36
47
///
37
48
/// This function _starts_ the created task on the calling context.
@@ -56,11 +67,11 @@ extension Task where Failure == ${FAILURE_TYPE} {
56
67
/// - Returns: A reference to the unstructured task which may be awaited on.
57
68
@available(SwiftStdlib 6.2, *)
58
69
@discardableResult
59
- public static func startSynchronously (
70
+ public static func immediate (
60
71
name: String? = nil,
61
72
priority: TaskPriority? = nil,
62
73
% # 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 } }`
64
75
@_implicitSelfCapture _ operation: __owned @isolated(any) @escaping () async throws -> Success
65
76
) -> Task<Success, ${FAILURE_TYPE}> {
66
77
@@ -109,7 +120,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
109
120
}
110
121
111
122
if canRunSynchronously {
112
- _startTaskSynchronously (task!, targetExecutor: builtinSerialExecutor)
123
+ _startTaskImmediately (task!, targetExecutor: builtinSerialExecutor)
113
124
}
114
125
return Task<Success, ${FAILURE_TYPE}>(task!)
115
126
}
@@ -121,35 +132,35 @@ GROUP_AND_OP_INFO = [
121
132
(
122
133
'TaskGroup',
123
134
[
124
- 'startTaskSynchronously ',
125
- 'startTaskSynchronouslyUnlessCancelled '
135
+ 'addImmediateTask ',
136
+ 'addImmediateTaskUnlessCancelled '
126
137
],
127
138
'',
128
139
'ChildTaskResult'
129
140
),
130
141
(
131
142
'ThrowingTaskGroup',
132
143
[
133
- 'startTaskSynchronously ',
134
- 'startTaskSynchronouslyUnlessCancelled '
144
+ 'addImmediateTask ',
145
+ 'addImmediateTaskUnlessCancelled '
135
146
],
136
147
'throws ',
137
148
'ChildTaskResult'
138
149
),
139
150
(
140
151
'DiscardingTaskGroup',
141
152
[
142
- 'startTaskSynchronously ',
143
- 'startTaskSynchronouslyUnlessCancelled '
153
+ 'addImmediateTask ',
154
+ 'addImmediateTaskUnlessCancelled '
144
155
],
145
156
'',
146
157
'Void'
147
158
),
148
159
(
149
160
'ThrowingDiscardingTaskGroup',
150
161
[
151
- 'startTaskSynchronously ',
152
- 'startTaskSynchronouslyUnlessCancelled '
162
+ 'addImmediateTask ',
163
+ 'addImmediateTaskUnlessCancelled '
153
164
],
154
165
'throws ',
155
166
'Void'
@@ -204,7 +215,7 @@ extension ${GROUP_TYPE} {
204
215
taskGroup: self._group,
205
216
operation: operation
206
217
)
207
- _startTaskSynchronously (task, targetExecutor: builtinSerialExecutor)
218
+ _startTaskImmediately (task, targetExecutor: builtinSerialExecutor)
208
219
}
209
220
}
210
221
% end # METHOD_NAMES
@@ -264,5 +275,5 @@ extension Task where Failure == ${FAILURE_TYPE} {
264
275
@_silgen_name("swift_task_startOnMainActor")
265
276
internal func _startTaskOnMainActor(_ task: Builtin.NativeObject)
266
277
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