Skip to content

Commit add063e

Browse files
committed
Add fast path for queue.async(flags: .barrier)
Replicate 6fe9b13 which fixes SR-2248 from the Darwin overlay to the wrapping overlay.
1 parent 6249878 commit add063e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/swift/Queue.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,15 @@ public extension DispatchQueue {
181181
flags: DispatchWorkItemFlags = [],
182182
execute work: @escaping @convention(block) () -> Void)
183183
{
184-
if group == nil && qos == .unspecified && flags.isEmpty {
184+
if group == nil && qos == .unspecified {
185185
// Fast-path route for the most common API usage
186-
CDispatch.dispatch_async(self.__wrapped, work)
187-
return
186+
if flags.isEmpty {
187+
CDispatch.dispatch_async(self.__wrapped, work)
188+
return
189+
} else if flags == .barrier {
190+
CDispatch.dispatch_barrier_async(self.__wrapped, work)
191+
return
192+
}
188193
}
189194

190195
var block: @convention(block) () -> Void = work

0 commit comments

Comments
 (0)