You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AsyncSerialQueue is a simple library to provide [serial queue](https://www.avanderlee.com/swift/concurrent-serial-dispatchqueue/)-like capability using [Swift Concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/). Tasks placed in an AsyncSerialQueue are guaranteed to execute sequentially.
9
+
`AsyncSerialQueue` is a library provides some useful patterns using Swift Concurrency:
10
+
11
+
`AsyncSerialQueue` is a class provides [serial queue](https://www.avanderlee.com/swift/concurrent-serial-dispatchqueue/)-like capability using [Swift Concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/). Tasks placed in an `AsyncSerialQueue` are guaranteed to execute sequentially.
12
+
13
+
`AsyncCoalescingQueue` is a companion class that has properties similar to [DispatchSource](https://www.mikeash.com/pyblog/friday-qa-2009-09-11-intro-to-grand-central-dispatch-part-iii-dispatch-sources.html).
10
14
11
15
AsyncSerialQueue is currently only available on Apple platforms (i.e. not on Linux). This is because of the need for locking and Swift [currently does not have a standard cross-platform locking mechnism](https://forums.swift.org/t/shared-mutable-state-sendable-and-locks/64336).
12
16
13
17
18
+
# `AsyncSerialQueue`
19
+
14
20
## Example
15
21
16
22
### Simple Example
@@ -100,3 +106,42 @@ func example() async {
100
106
101
107
In this case, `apple` will never appear before `2`. And `example()` will not return until `2` is printed.
Copy file name to clipboardExpand all lines: Sources/AsyncSerialQueue/AsyncCoalescingQueue.swift
+31-6Lines changed: 31 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,42 @@
8
8
import Foundation
9
9
import os
10
10
11
-
/// Provides behavior similar to DispatchSource using Swift Concurrency
11
+
/// ``AsyncCoalescingQueue`` provides behavior similar to DispatchSource using Swift Concurrency
12
+
/// When the queue is idle, the first task queued is guaranteed to run. Subsequent tasks will only execute when the queue is idle. If more the one task is pending execution, only the last one will execute.
0 commit comments