Skip to content

Commit

Permalink
Add asyncAfter method
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed May 27, 2023
2 parents 4897a73 + 880aeae commit 4592824
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/Concurrency/DispatchQueue/IDispatchQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ public protocol IDispatchQueue: AnyObject {
///
/// - Parameter workItem: The work item to be invoked on the queue.
func sync(execute workItem: DispatchWorkItem)

///
/// Submits a work item to a dispatch queue for asynchronous execution after
/// a specified time.
///
/// - parameter: deadline the time after which the work item should be executed,
/// given as a `DispatchTime`.
/// - parameter execute: The work item to be invoked on the queue.
/// - SeeAlso: `asyncAfter(deadline:qos:flags:execute:)`
/// - SeeAlso: `DispatchTime`
///
func asyncAfter(deadline: DispatchTime, execute: DispatchWorkItem)
}

public extension IDispatchQueue {
Expand Down
4 changes: 4 additions & 0 deletions Sources/TestConcurrency/TestDispatchQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ extension TestDispatchQueue: IDispatchQueue {
public func sync(execute workItem: DispatchWorkItem) {
workItem.perform()
}

public func asyncAfter(deadline _: DispatchTime, execute: DispatchWorkItem) {
execute.perform()
}
}

0 comments on commit 4592824

Please sign in to comment.