Skip to content

Commit

Permalink
waitUntilAllOperationsAreFinished(timeout:) now takes Optional time…
Browse files Browse the repository at this point in the history
…out parameter
  • Loading branch information
orchetect committed Jan 19, 2023
1 parent 836cad2 commit 6c90fbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,8 @@ extension AtomicBlockOperation {
}

/// Blocks the current thread until all the receiver’s queued and executing operations finish executing.
public func waitUntilAllOperationsAreFinished(timeout: TimeInterval? = nil) {
if let timeout = timeout {
operationQueue.waitUntilAllOperationsAreFinished(timeout: timeout)
} else {
operationQueue.waitUntilAllOperationsAreFinished()
}
public func waitUntilAllQueueOperationsAreFinished(timeout: TimeInterval? = nil) {
operationQueue.waitUntilAllOperationsAreFinished(timeout: timeout)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ extension OperationQueue {
/// executing. Same as calling `waitUntilAllOperationsAreFinished()` but offers a timeout duration.
@discardableResult
public func waitUntilAllOperationsAreFinished(
timeout: TimeInterval
timeout: TimeInterval? = nil
) -> DispatchTimeoutResult {
// no timeout

guard let timeout = timeout else {
self.waitUntilAllOperationsAreFinished()
return .success
}

// with timeout

let g = DispatchGroup()
g.enter()

Expand Down

0 comments on commit 6c90fbb

Please sign in to comment.