@@ -147,10 +147,13 @@ extension Task {
147147 /// it only makes it impossible for you to explicitly cancel the task.
148148 ///
149149 /// - Parameters:
150+ /// - name: Human readable name of the task.
151+ /// - priority: The priority of the operation task.
150152 /// - actorQueue: The queue on which to enqueue the task.
151153 /// - operation: The operation to perform.
152154 @discardableResult
153155 public init < ActorType: Actor > (
156+ name: String ? = nil ,
154157 priority: TaskPriority ? = nil ,
155158 on actorQueue: ActorQueue < ActorType > ,
156159 operation: @Sendable @escaping ( isolated ActorType) async -> Success
@@ -163,11 +166,11 @@ extension Task {
163166 await semaphore. wait ( )
164167 delivery. execute ( { @Sendable executionContext in
165168 await delivery. sendValue ( operation ( executionContext) )
166- } , in: executionContext, priority: priority)
169+ } , in: executionContext, name : name , priority: priority)
167170 }
168171 )
169172 actorQueue. taskStreamContinuation. yield ( task)
170- self . init ( priority: priority) {
173+ self . init ( name : name , priority: priority) {
171174 await withTaskCancellationHandler (
172175 operation: {
173176 await semaphore. signal ( )
@@ -200,12 +203,14 @@ extension Task {
200203 /// it only makes it impossible for you to explicitly cancel the task.
201204 ///
202205 /// - Parameters:
206+ /// - name: Human readable name of the task.
203207 /// - priority: The priority of the task.
204208 /// Pass `nil` to use the priority from `Task.currentPriority`.
205209 /// - actorQueue: The queue on which to enqueue the task.
206210 /// - operation: The operation to perform.
207211 @discardableResult
208212 public init < ActorType: Actor > (
213+ name: String ? = nil ,
209214 priority: TaskPriority ? = nil ,
210215 on actorQueue: ActorQueue < ActorType > ,
211216 operation: @escaping @Sendable ( isolated ActorType) async throws -> Success
@@ -222,11 +227,11 @@ extension Task {
222227 } catch {
223228 await delivery. sendFailure ( error)
224229 }
225- } , in: executionContext, priority: priority)
230+ } , in: executionContext, name : name , priority: priority)
226231 }
227232 )
228233 actorQueue. taskStreamContinuation. yield ( task)
229- self . init ( priority: priority) {
234+ self . init ( name : name , priority: priority) {
230235 try await withTaskCancellationHandler (
231236 operation: {
232237 await semaphore. signal ( )
@@ -259,12 +264,14 @@ extension Task {
259264 /// it only makes it impossible for you to explicitly cancel the task.
260265 ///
261266 /// - Parameters:
267+ /// - name: Human readable name of the task.
262268 /// - priority: The priority of the task.
263269 /// Pass `nil` to use the priority from `Task.currentPriority`.
264270 /// - actorQueue: The queue on which to enqueue the task.
265271 /// - operation: The operation to perform.
266272 @discardableResult
267273 public init (
274+ name: String ? = nil ,
268275 priority: TaskPriority ? = nil ,
269276 on actorQueue: ActorQueue < MainActor > ,
270277 operation: @MainActor @escaping ( ) async -> Success
@@ -277,11 +284,11 @@ extension Task {
277284 await semaphore. wait ( )
278285 delivery. execute ( { @Sendable executionContext in
279286 await delivery. sendValue ( operation ( ) )
280- } , in: executionContext, priority: priority)
287+ } , in: executionContext, name : name , priority: priority)
281288 }
282289 )
283290 actorQueue. taskStreamContinuation. yield ( task)
284- self . init ( priority: priority) {
291+ self . init ( name : name , priority: priority) {
285292 await withTaskCancellationHandler (
286293 operation: {
287294 await semaphore. signal ( )
@@ -314,12 +321,14 @@ extension Task {
314321 /// it only makes it impossible for you to explicitly cancel the task.
315322 ///
316323 /// - Parameters:
324+ /// - name: Human readable name of the task.
317325 /// - priority: The priority of the task.
318326 /// Pass `nil` to use the priority from `Task.currentPriority`.
319327 /// - actorQueue: The queue on which to enqueue the task.
320328 /// - operation: The operation to perform.
321329 @discardableResult
322330 public init (
331+ name: String ? = nil ,
323332 priority: TaskPriority ? = nil ,
324333 on actorQueue: ActorQueue < MainActor > ,
325334 operation: @escaping @MainActor ( ) async throws -> Success
@@ -336,11 +345,11 @@ extension Task {
336345 } catch {
337346 await delivery. sendFailure ( error)
338347 }
339- } , in: executionContext, priority: priority)
348+ } , in: executionContext, name : name , priority: priority)
340349 }
341350 )
342351 actorQueue. taskStreamContinuation. yield ( task)
343- self . init ( priority: priority) {
352+ self . init ( name : name , priority: priority) {
344353 try await withTaskCancellationHandler (
345354 operation: {
346355 await semaphore. signal ( )
0 commit comments