@@ -98,7 +98,7 @@ extension Task {
98
98
/// i.e. the task will run regardless of the handle still being present or not.
99
99
/// Dropping a handle however means losing the ability to await on the task's result
100
100
/// and losing the ability to cancel it.
101
- public final class Handle < Success, Failure : Error > {
101
+ public final class Handle < Success> {
102
102
/// Wait for the task to complete, returning (or throwing) its result.
103
103
///
104
104
/// ### Priority
@@ -107,7 +107,12 @@ extension Task {
107
107
/// creating the task with the "right" priority to in the first place.
108
108
///
109
109
/// ### Cancellation
110
- /// If the awaited on task gets cancelled the `get()` will throw a cancellation error.
110
+ /// If the awaited on task gets cancelled externally the `get()` will throw
111
+ /// a cancellation error.
112
+ ///
113
+ /// If the task gets cancelled internally, e.g. by checking for cancellation
114
+ /// and throwing a specific error or using `checkCancellation` the error
115
+ /// thrown out of the task will be re-thrown here.
111
116
public func get( ) async throws -> Success {
112
117
fatalError ( " \( #function) not implemented yet. " )
113
118
}
@@ -147,21 +152,21 @@ extension Task {
147
152
///
148
153
/// Canceling a task must be performed explicitly via `handle.cancel()`.
149
154
///
150
- /// - Parameters:
151
- /// - priority: priority of the task TODO: reword and define more explicitly once we have priorities well-defined
152
- /// - operation:
153
- /// - Returns: handle to the task, allowing to `await handle.get()` on the
154
- /// tasks result or `cancel` it.
155
- ///
156
155
/// - Note: it is generally preferable to use child tasks rather than detached
157
156
/// tasks. Child tasks automatically carry priorities, task-local state,
158
157
/// deadlines and have other benefits resulting from the structured
159
158
/// concurrency concepts that they model. Consider using detached tasks only
160
159
/// when strictly necessary and impossible to model operations otherwise.
160
+ ///
161
+ /// - Parameters:
162
+ /// - priority: priority of the task TODO: reword and define more explicitly once we have priorities well-defined
163
+ /// - operation: the operation to execute
164
+ /// - Returns: handle to the task, allowing to `await handle.get()` on the
165
+ /// tasks result or `cancel` it.
161
166
public static func runDetached< T> (
162
167
priority: Priority = . default,
163
168
operation: ( ) async -> T
164
- ) -> Handle < T , Never > {
169
+ ) -> Handle < T > {
165
170
fatalError ( " \( #function) not implemented yet. " )
166
171
}
167
172
@@ -183,22 +188,22 @@ extension Task {
183
188
///
184
189
/// Canceling a task must be performed explicitly via `handle.cancel()`.
185
190
///
186
- /// - Parameters:
187
- /// - priority: priority of the task TODO: reword and define more explicitly once we have priorities well-defined
188
- /// - operation:
189
- /// - Returns: handle to the task, allowing to `await handle.get()` on the
190
- /// tasks result or `cancel` it. If the operation fails the handle will
191
- /// throw the error the operation has thrown when awaited on.
192
- ///
193
191
/// - Note: it is generally preferable to use child tasks rather than detached
194
192
/// tasks. Child tasks automatically carry priorities, task-local state,
195
193
/// deadlines and have other benefits resulting from the structured
196
194
/// concurrency concepts that they model. Consider using detached tasks only
197
195
/// when strictly necessary and impossible to model operations otherwise.
196
+ ///
197
+ /// - Parameters:
198
+ /// - priority: priority of the task TODO: reword and define more explicitly once we have priorities well-defined
199
+ /// - operation: the operation to execute
200
+ /// - Returns: handle to the task, allowing to `await handle.get()` on the
201
+ /// tasks result or `cancel` it. If the operation fails the handle will
202
+ /// throw the error the operation has thrown when awaited on.
198
203
public static func runDetached< T> (
199
204
priority: Priority = . default,
200
205
operation: ( ) async throws -> T
201
- ) -> Handle < T , Error > {
206
+ ) -> Handle < T > {
202
207
fatalError ( " \( #function) not implemented yet. " )
203
208
}
204
209
}
0 commit comments