Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Concurrency/TaskFactory/ITaskFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Foundation
/// - operation: An asynchronous operation to execute within the task. The operation
/// inherits the current actor context and is isolated to that actor.
/// - Returns: A `Task` object that wraps the result or error of the operation.
@discardableResult
func task<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
Expand All @@ -30,6 +31,7 @@ import Foundation
/// - operation: An asynchronous operation to execute within the task. The operation
/// inherits the current actor context and is isolated to that actor.
/// - Returns: A `Task` object that wraps the result of the operation.
@discardableResult
func task<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
Expand All @@ -42,6 +44,7 @@ import Foundation
/// - operation: An asynchronous operation to execute within the task. The operation
/// is isolated and does not inherit the current actor context.
/// - Returns: A `Task` object that wraps the result or error of the operation.
@discardableResult
func detached<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
Expand All @@ -54,6 +57,7 @@ import Foundation
/// - operation: An asynchronous operation to execute within the task. The operation
/// is isolated and does not inherit the current actor context.
/// - Returns: A `Task` object that wraps the result of the operation.
@discardableResult
func detached<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
Expand All @@ -66,6 +70,7 @@ import Foundation
/// that can throw errors.
/// - Parameter operation: An asynchronous operation to execute within the task.
/// - Returns: A `Task` object that wraps the result or error of the operation.
@discardableResult
func task<Success: Sendable>(
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
) -> Task<Success, Error> {
Expand All @@ -76,6 +81,7 @@ import Foundation
/// that does not throw errors.
/// - Parameter operation: An asynchronous operation to execute within the task.
/// - Returns: A `Task` object that wraps the result of the operation.
@discardableResult
func task<Success: Sendable>(
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
) -> Task<Success, Never> {
Expand All @@ -86,6 +92,7 @@ import Foundation
/// of the current actor context and can throw errors.
/// - Parameter operation: An asynchronous operation to execute within the task.
/// - Returns: A `Task` object that wraps the result or error of the operation.
@discardableResult
func detached<Success: Sendable>(
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
) -> Task<Success, Error> {
Expand All @@ -96,6 +103,7 @@ import Foundation
/// of the current actor context and does not throw errors.
/// - Parameter operation: An asynchronous operation to execute within the task.
/// - Returns: A `Task` object that wraps the result of the operation.
@discardableResult
func detached<Success: Sendable>(
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
) -> Task<Success, Never> {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Concurrency/TaskFactory/TaskFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@

// MARK: ITaskFactory

@discardableResult
public func task<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
) -> Task<Success, Error> {
Task(priority: priority, operation: operation)
}

@discardableResult
public func task<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
) -> Task<Success, Never> {
Task(priority: priority, operation: operation)
}

@discardableResult
public func detached<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
) -> Task<Success, Error> {
Task.detached(priority: priority, operation: operation)
}

@discardableResult
public func detached<Success: Sendable>(
priority: TaskPriority?,
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
Expand Down