|
14 | 14 | //===----------------------------------------------------------------------===// |
15 | 15 |
|
16 | 16 | import Swift |
17 | | -import _Concurrency |
18 | 17 |
|
19 | 18 | @available(SwiftStdlib 5.1, *) |
20 | 19 | extension Task where Success == Never, Failure == Never { |
@@ -88,192 +87,23 @@ extension Task where Success == Never, Failure == Never { |
88 | 87 | } |
89 | 88 | } |
90 | 89 |
|
91 | | -//@available(SwiftStdlib 5.1, *) |
92 | | -//extension Task where Failure == Error { |
93 | | -// #if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
94 | | -// @discardableResult |
95 | | -// @_alwaysEmitIntoClient |
96 | | -// @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
97 | | -// public static func runDetached( |
98 | | -// priority: TaskPriority? = nil, |
99 | | -// operation: __owned @Sendable @escaping () async throws -> Success |
100 | | -// ) -> Task<Success, Failure> { |
101 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
102 | | -// } |
103 | | -// #else |
104 | | -// @discardableResult |
105 | | -// @_alwaysEmitIntoClient |
106 | | -// @available(*, deprecated, message: "`Task.runDetached` was replaced by `Task.detached` and will be removed shortly.") |
107 | | -// public static func runDetached( |
108 | | -// priority: TaskPriority? = nil, |
109 | | -// operation: __owned @Sendable @escaping () async throws -> Success |
110 | | -// ) -> Task<Success, Failure> { |
111 | | -// detached(priority: priority, operation: operation) |
112 | | -// } |
113 | | -// #endif |
114 | | -//} |
115 | | -// |
116 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
117 | | -//@discardableResult |
118 | | -//@available(SwiftStdlib 5.1, *) |
119 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
120 | | -//@_alwaysEmitIntoClient |
121 | | -//public func detach<T>( |
122 | | -// priority: TaskPriority? = nil, |
123 | | -// operation: __owned @Sendable @escaping () async -> T |
124 | | -//) -> Task<T, Never> { |
125 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
126 | | -//} |
127 | | -//#else |
128 | | -//@discardableResult |
129 | | -//@available(SwiftStdlib 5.1, *) |
130 | | -//@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.") |
131 | | -//@_alwaysEmitIntoClient |
132 | | -//public func detach<T>( |
133 | | -// priority: TaskPriority? = nil, |
134 | | -// operation: __owned @Sendable @escaping () async -> T |
135 | | -//) -> Task<T, Never> { |
136 | | -// Task.detached(priority: priority, operation: operation) |
137 | | -//} |
138 | | -//#endif |
139 | | -// |
140 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
141 | | -//@discardableResult |
142 | | -//@available(SwiftStdlib 5.1, *) |
143 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
144 | | -//@_alwaysEmitIntoClient |
145 | | -//public func detach<T>( |
146 | | -// priority: TaskPriority? = nil, |
147 | | -// operation: __owned @Sendable @escaping () async throws -> T |
148 | | -//) -> Task<T, Error> { |
149 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
150 | | -//} |
151 | | -//#else |
152 | | -//@discardableResult |
153 | | -//@available(SwiftStdlib 5.1, *) |
154 | | -//@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.") |
155 | | -//@_alwaysEmitIntoClient |
156 | | -//public func detach<T>( |
157 | | -// priority: TaskPriority? = nil, |
158 | | -// operation: __owned @Sendable @escaping () async throws -> T |
159 | | -//) -> Task<T, Error> { |
160 | | -// Task.detached(priority: priority, operation: operation) |
161 | | -//} |
162 | | -//#endif |
163 | | -// |
164 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
165 | | -//@discardableResult |
166 | | -//@available(SwiftStdlib 5.1, *) |
167 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
168 | | -//@_alwaysEmitIntoClient |
169 | | -//public func asyncDetached<T>( |
170 | | -// priority: TaskPriority? = nil, |
171 | | -// @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T |
172 | | -//) -> Task<T, Never> { |
173 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
174 | | -//} |
175 | | -//#else |
176 | | -//@discardableResult |
177 | | -//@available(SwiftStdlib 5.1, *) |
178 | | -//@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.") |
179 | | -//@_alwaysEmitIntoClient |
180 | | -//public func asyncDetached<T>( |
181 | | -// priority: TaskPriority? = nil, |
182 | | -// @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T |
183 | | -//) -> Task<T, Never> { |
184 | | -// return Task.detached(priority: priority, operation: operation) |
185 | | -//} |
186 | | -//#endif |
187 | | -// |
188 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
189 | | -//@discardableResult |
190 | | -//@available(SwiftStdlib 5.1, *) |
191 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
192 | | -//@_alwaysEmitIntoClient |
193 | | -//public func asyncDetached<T>( |
194 | | -// priority: TaskPriority? = nil, |
195 | | -// @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T |
196 | | -//) -> Task<T, Error> { |
197 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
198 | | -//} |
199 | | -//#else |
200 | | -//@discardableResult |
201 | | -//@available(SwiftStdlib 5.1, *) |
202 | | -//@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.") |
203 | | -//@_alwaysEmitIntoClient |
204 | | -//public func asyncDetached<T>( |
205 | | -// priority: TaskPriority? = nil, |
206 | | -// @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T |
207 | | -//) -> Task<T, Error> { |
208 | | -// return Task.detached(priority: priority, operation: operation) |
209 | | -//} |
210 | | -//#endif |
211 | | -// |
212 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
213 | | -//@available(SwiftStdlib 5.1, *) |
214 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
215 | | -//@discardableResult |
216 | | -//@_alwaysEmitIntoClient |
217 | | -//public func async<T>( |
218 | | -// priority: TaskPriority? = nil, |
219 | | -// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T |
220 | | -//) -> Task<T, Never> { |
221 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
222 | | -//} |
223 | | -//#else |
224 | | -//@available(SwiftStdlib 5.1, *) |
225 | | -//@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.") |
226 | | -//@discardableResult |
227 | | -//@_alwaysEmitIntoClient |
228 | | -//public func async<T>( |
229 | | -// priority: TaskPriority? = nil, |
230 | | -// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T |
231 | | -//) -> Task<T, Never> { |
232 | | -// .init(priority: priority, operation: operation) |
233 | | -//} |
234 | | -//#endif |
235 | | -// |
236 | | -//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY |
237 | | -//@available(SwiftStdlib 5.1, *) |
238 | | -//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") |
239 | | -//@discardableResult |
240 | | -//@_alwaysEmitIntoClient |
241 | | -//public func async<T>( |
242 | | -// priority: TaskPriority? = nil, |
243 | | -// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T |
244 | | -//) -> Task<T, Error> { |
245 | | -// fatalError("Unavailable in task-to-thread concurrency model") |
246 | | -//} |
247 | | -//#else |
248 | | -//@available(SwiftStdlib 5.1, *) |
249 | | -//@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.") |
250 | | -//@discardableResult |
251 | | -//@_alwaysEmitIntoClient |
252 | | -//public func async<T>( |
253 | | -// priority: TaskPriority? = nil, |
254 | | -// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T |
255 | | -//) -> Task<T, Error> { |
256 | | -// .init(priority: priority, operation: operation) |
257 | | -//} |
258 | | -//#endif |
259 | | -// |
260 | | -//@available(SwiftStdlib 5.1, *) |
261 | | -//extension Task where Success == Never, Failure == Never { |
262 | | -// @available(*, deprecated, message: "`Task.Group` was replaced by `ThrowingTaskGroup` and `TaskGroup` and will be removed shortly.") |
263 | | -// public typealias Group<TaskResult: Sendable> = ThrowingTaskGroup<TaskResult, Error> |
264 | | -// |
265 | | -// @available(*, deprecated, message: "`Task.withGroup` was replaced by `withThrowingTaskGroup` and `withTaskGroup` and will be removed shortly.") |
266 | | -// @_alwaysEmitIntoClient |
267 | | -// public static func withGroup<TaskResult: Sendable, BodyResult>( |
268 | | -// resultType: TaskResult.Type, |
269 | | -// returning returnType: BodyResult.Type = BodyResult.self, |
270 | | -// body: (inout Task.Group<TaskResult>) async throws -> BodyResult |
271 | | -// ) async rethrows -> BodyResult { |
272 | | -// try await withThrowingTaskGroup(of: resultType) { group in |
273 | | -// try await body(&group) |
274 | | -// } |
275 | | -// } |
276 | | -//} |
| 90 | +@available(SwiftStdlib 5.1, *) |
| 91 | +extension Task where Success == Never, Failure == Never { |
| 92 | + @available(*, deprecated, message: "`Task.Group` was replaced by `ThrowingTaskGroup` and `TaskGroup` and will be removed shortly.") |
| 93 | + public typealias Group<TaskResult: Sendable> = ThrowingTaskGroup<TaskResult, Error> |
| 94 | + |
| 95 | + @available(*, deprecated, message: "`Task.withGroup` was replaced by `withThrowingTaskGroup` and `withTaskGroup` and will be removed shortly.") |
| 96 | + @_alwaysEmitIntoClient |
| 97 | + public static func withGroup<TaskResult: Sendable, BodyResult>( |
| 98 | + resultType: TaskResult.Type, |
| 99 | + returning returnType: BodyResult.Type = BodyResult.self, |
| 100 | + body: (inout Task.Group<TaskResult>) async throws -> BodyResult |
| 101 | + ) async rethrows -> BodyResult { |
| 102 | + try await withThrowingTaskGroup(of: resultType) { group in |
| 103 | + try await body(&group) |
| 104 | + } |
| 105 | + } |
| 106 | +} |
277 | 107 |
|
278 | 108 | @available(SwiftStdlib 5.1, *) |
279 | 109 | extension Task { |
|
0 commit comments