Skip to content

Commit 1f17a65

Browse files
Weak reference operation to avoid strong reference capture in closure (#444)
1 parent 3040916 commit 1f17a65

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Sources/SwiftQueue/Constraint+Timeout.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ internal final class TimeoutConstraint: SimpleConstraint, CodableConstraint {
3939
}
4040

4141
override func run(operation: SqOperation) -> Bool {
42-
operation.dispatchQueue.runAfter(timeout) {
42+
operation.dispatchQueue.runAfter(timeout) { [weak operation] in
43+
guard let operation else { return }
4344
if operation.isExecuting && !operation.isFinished {
4445
operation.cancel(with: SwiftQueueError.timeout)
4546
}

0 commit comments

Comments
 (0)