Skip to content

Commit 7ead5bc

Browse files
rmazneakor
authored andcommitted
signal before recursion (#25)
1 parent 0845568 commit 7ead5bc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Sources/Concurrency/Executor/ConcurrentSequenceExecutor.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ public class ConcurrentSequenceExecutor: SequenceExecutor {
7272
private func execute<SequenceResultType>(_ task: Task, with sequenceHandle: SynchronizedSequenceExecutionHandle<SequenceResultType>, _ execution: @escaping (Task, Any) -> SequenceExecution<SequenceResultType>) {
7373
taskSemaphore?.wait()
7474
taskQueue.async {
75-
if let taskSemaphore = self.taskSemaphore {
76-
defer {
77-
taskSemaphore.signal()
78-
}
79-
}
80-
8175
guard !sequenceHandle.isCancelled else {
76+
self.taskSemaphore?.signal()
8277
return
8378
}
8479

@@ -88,6 +83,8 @@ public class ConcurrentSequenceExecutor: SequenceExecutor {
8883

8984
let result = task.typeErasedExecute()
9085
let nextExecution = execution(task, result)
86+
self.taskSemaphore?.signal()
87+
9188
switch nextExecution {
9289
case .continueSequence(let nextTask):
9390
self.execute(nextTask, with: sequenceHandle, execution)

0 commit comments

Comments
 (0)