Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions Sources/AsyncQueue/ActorQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ public final class ActorQueue<ActorType: Actor>: @unchecked Sendable {
// MARK: Initialization

/// Instantiates an actor queue.
public init() {
/// - Parameter name: Human readable name of the task.
public init(name: String? = nil) {
let (taskStream, taskStreamContinuation) = AsyncStream<ActorTask>.makeStream()
self.taskStreamContinuation = taskStreamContinuation

Task {
Task(name: name) {
// In an ideal world, we would isolate this `for await` loop to the `ActorType`.
// However, there's no good way to do that without retaining the actor and creating a cycle.
for await actorTask in taskStream {
Expand Down
5 changes: 3 additions & 2 deletions Sources/AsyncQueue/FIFOQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public final class FIFOQueue: Sendable {
// MARK: Initialization

/// Instantiates a FIFO queue.
/// - Parameter name: Human readable name of the task.
/// - Parameter priority: The baseline priority of the tasks added to the asynchronous queue.
public init(priority: TaskPriority? = nil) {
public init(name: String? = nil, priority: TaskPriority? = nil) {
let (taskStream, taskStreamContinuation) = AsyncStream<FIFOTask>.makeStream()
self.taskStreamContinuation = taskStreamContinuation

Task.detached(priority: priority) {
Task.detached(name: name, priority: priority) {
for await fifoTask in taskStream {
await fifoTask.task()
}
Expand Down
Loading