Skip to content

Commit 880aeae

Browse files
committed
Add asyncAfter method
1 parent ff7aa2a commit 880aeae

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/Concurrency/DispatchQueue/IDispatchQueue.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ public protocol IDispatchQueue: AnyObject {
9292
///
9393
/// - Parameter workItem: The work item to be invoked on the queue.
9494
func sync(execute workItem: DispatchWorkItem)
95+
96+
///
97+
/// Submits a work item to a dispatch queue for asynchronous execution after
98+
/// a specified time.
99+
///
100+
/// - parameter: deadline the time after which the work item should be executed,
101+
/// given as a `DispatchTime`.
102+
/// - parameter execute: The work item to be invoked on the queue.
103+
/// - SeeAlso: `asyncAfter(deadline:qos:flags:execute:)`
104+
/// - SeeAlso: `DispatchTime`
105+
///
106+
func asyncAfter(deadline: DispatchTime, execute: DispatchWorkItem)
95107
}
96108

97109
public extension IDispatchQueue {

Sources/TestConcurrency/TestDispatchQueue.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ extension TestDispatchQueue: IDispatchQueue {
4747
public func sync(execute workItem: DispatchWorkItem) {
4848
workItem.perform()
4949
}
50+
51+
public func asyncAfter(deadline _: DispatchTime, execute: DispatchWorkItem) {
52+
execute.perform()
53+
}
5054
}

0 commit comments

Comments
 (0)