Skip to content

Commit b30374b

Browse files
authored
Add priority to more initializers (#69)
1 parent c1498bb commit b30374b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Sources/AsyncQueue/FIFOQueue.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ extension Task {
8181
///
8282
/// - Parameters:
8383
/// - name: Human readable name of the task.
84+
/// - priority: The priority of the task.
8485
/// - fifoQueue: The queue on which to enqueue the task.
8586
/// - operation: The operation to perform.
8687
@discardableResult
8788
public init(
8889
name: String? = nil,
90+
priority: TaskPriority? = nil,
8991
on fifoQueue: FIFOQueue,
9092
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping @isolated(any) () async -> Success,
9193
) where Failure == Never {
@@ -96,7 +98,7 @@ extension Task {
9698
await semaphore.wait()
9799
await delivery.execute({ @Sendable delivery in
98100
await delivery.sendValue(executeOnce.operation())
99-
}, in: delivery, name: name).value
101+
}, in: delivery, name: name, priority: priority).value
100102
}
101103
fifoQueue.taskStreamContinuation.yield(task)
102104
self.init(name: name) {
@@ -133,11 +135,13 @@ extension Task {
133135
///
134136
/// - Parameters:
135137
/// - name: Human readable name of the task.
138+
/// - priority: The priority of the task.
136139
/// - fifoQueue: The queue on which to enqueue the task.
137140
/// - operation: The operation to perform.
138141
@discardableResult
139142
public init(
140143
name: String? = nil,
144+
priority: TaskPriority? = nil,
141145
on fifoQueue: FIFOQueue,
142146
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping @isolated(any) () async throws -> Success,
143147
) where Failure == any Error {
@@ -152,7 +156,7 @@ extension Task {
152156
} catch {
153157
delivery.sendFailure(error)
154158
}
155-
}, in: delivery, name: name).value
159+
}, in: delivery, name: name, priority: priority).value
156160
}
157161
fifoQueue.taskStreamContinuation.yield(task)
158162
self.init(name: name) {

Sources/AsyncQueue/Utilities/Delivery.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ actor Delivery<Success: Sendable, Failure: Error> {
4242
func execute<ActorType: Actor>(
4343
_ operation: sending @escaping (isolated ActorType) async -> Void,
4444
in context: isolated ActorType,
45-
name: String? = nil,
46-
priority: TaskPriority? = nil,
45+
name: String?,
46+
priority: TaskPriority?,
4747
) -> Task<Void, Never> {
4848
// In Swift 6, a `Task` enqueued from an actor begins executing immediately on that actor.
4949
// Since we're running on our actor's context already, we can just dispatch a Task to get first-enqueued-first-start task execution.

0 commit comments

Comments
 (0)