Skip to content

Commit 9661109

Browse files
authored
Merge pull request #37068 from DougGregor/async-detached
2 parents 712e439 + ff4b0f3 commit 9661109

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,26 @@ public func detach<T>(
437437
return Task.Handle<T, Error>(task)
438438
}
439439

440+
@discardableResult
441+
@_alwaysEmitIntoClient
442+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
443+
public func asyncDetached<T>(
444+
priority: Task.Priority = .unspecified,
445+
operation: __owned @Sendable @escaping () async -> T
446+
) -> Task.Handle<T, Never> {
447+
return detach(priority: priority, operation: operation)
448+
}
449+
450+
@discardableResult
451+
@_alwaysEmitIntoClient
452+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
453+
public func asyncDetached<T>(
454+
priority: Task.Priority = .unspecified,
455+
operation: __owned @Sendable @escaping () async throws -> T
456+
) -> Task.Handle<T, Error> {
457+
return detach(priority: priority, operation: operation)
458+
}
459+
440460
/// Run given `operation` as asynchronously in its own top-level task.
441461
///
442462
/// The `async` function should be used when creating asynchronous work

0 commit comments

Comments
 (0)