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: 6 additions & 2 deletions Sources/AsyncQueue/FIFOQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ extension Task {
///
/// - Parameters:
/// - name: Human readable name of the task.
/// - priority: The priority of the task.
/// - fifoQueue: The queue on which to enqueue the task.
/// - operation: The operation to perform.
@discardableResult
public init(
name: String? = nil,
priority: TaskPriority? = nil,
on fifoQueue: FIFOQueue,
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping @isolated(any) () async -> Success,
) where Failure == Never {
Expand All @@ -96,7 +98,7 @@ extension Task {
await semaphore.wait()
await delivery.execute({ @Sendable delivery in
await delivery.sendValue(executeOnce.operation())
}, in: delivery, name: name).value
}, in: delivery, name: name, priority: priority).value
}
fifoQueue.taskStreamContinuation.yield(task)
self.init(name: name) {
Expand Down Expand Up @@ -133,11 +135,13 @@ extension Task {
///
/// - Parameters:
/// - name: Human readable name of the task.
/// - priority: The priority of the task.
/// - fifoQueue: The queue on which to enqueue the task.
/// - operation: The operation to perform.
@discardableResult
public init(
name: String? = nil,
priority: TaskPriority? = nil,
on fifoQueue: FIFOQueue,
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping @isolated(any) () async throws -> Success,
) where Failure == any Error {
Expand All @@ -152,7 +156,7 @@ extension Task {
} catch {
delivery.sendFailure(error)
}
}, in: delivery, name: name).value
}, in: delivery, name: name, priority: priority).value
}
fifoQueue.taskStreamContinuation.yield(task)
self.init(name: name) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncQueue/Utilities/Delivery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ actor Delivery<Success: Sendable, Failure: Error> {
func execute<ActorType: Actor>(
_ operation: sending @escaping (isolated ActorType) async -> Void,
in context: isolated ActorType,
name: String? = nil,
priority: TaskPriority? = nil,
name: String?,
priority: TaskPriority?,
Comment on lines +45 to +46
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core change here has the compiler helping me discover where we've missed these

) -> Task<Void, Never> {
// In Swift 6, a `Task` enqueued from an actor begins executing immediately on that actor.
// Since we're running on our actor's context already, we can just dispatch a Task to get first-enqueued-first-start task execution.
Expand Down