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
10 changes: 5 additions & 5 deletions Sources/Concurrency/Executor/ConcurrentSequenceExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public class ConcurrentSequenceExecutor: SequenceExecutor {
/// - parameter name: The name of the executor.
/// - parameter qos: The quality of service of this executor. This
/// defaults to `userInitiated`.
/// - parameter shouldTackTaskId: `true` if task IDs should be tracked
/// - parameter shouldTrackTaskId: `true` if task IDs should be tracked
/// as tasks are executed. `false` otherwise. By tracking the task IDs,
/// if waiting on the completion of a task sequence times out, the
/// reported error contains the ID of the task that was being executed
/// when the timeout occurred. The tracking does incur a minor
/// performance cost. This value defaults to `false`.
public init(name: String, qos: DispatchQoS = .userInitiated, shouldTackTaskId: Bool = false) {
public init(name: String, qos: DispatchQoS = .userInitiated, shouldTrackTaskId: Bool = false) {
taskQueue = DispatchQueue(label: "Executor.taskQueue-\(name)", qos: qos, attributes: .concurrent)
self.shouldTackTaskId = shouldTackTaskId
self.shouldTrackTaskId = shouldTrackTaskId
}

/// Execute a sequence of tasks concurrently from the given initial task.
Expand All @@ -58,15 +58,15 @@ public class ConcurrentSequenceExecutor: SequenceExecutor {
// MARK: - Private

private let taskQueue: DispatchQueue
private let shouldTackTaskId: Bool
private let shouldTrackTaskId: Bool

private func execute<SequenceResultType>(_ task: Task, with sequenceHandle: SynchronizedSequenceExecutionHandle<SequenceResultType>, _ execution: @escaping (Task, Any) -> SequenceExecution<SequenceResultType>) {
taskQueue.async {
guard !sequenceHandle.isCancelled else {
return
}

if self.shouldTackTaskId {
if self.shouldTrackTaskId {
sequenceHandle.willBeginExecuting(taskId: task.id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ConcurrentSequenceExecutorTests: XCTestCase {
}

func test_executeSequence_withNonTerminatingSequence_withTimeout_verifyAwaitTimeout() {
let executor = ConcurrentSequenceExecutor(name: "test_executeSequence_withNonTerminatingSequence_withTimeout_verifyAwaitTimeout", shouldTackTaskId: true)
let executor = ConcurrentSequenceExecutor(name: "test_executeSequence_withNonTerminatingSequence_withTimeout_verifyAwaitTimeout", shouldTrackTaskId: true)

let sequencedTask = MockSelfRepeatingTask(id: 123) {
return 0
Expand Down