From add063e4a111ea8af79025a7074f8a07a239d73d Mon Sep 17 00:00:00 2001 From: David Grove Date: Fri, 9 Sep 2016 18:17:19 -0400 Subject: [PATCH] Add fast path for queue.async(flags: .barrier) Replicate 6fe9b13f12fc34d80c8c63cce84fa3667424baaf which fixes SR-2248 from the Darwin overlay to the wrapping overlay. --- src/swift/Queue.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/swift/Queue.swift b/src/swift/Queue.swift index 8db1b6872..155be8aff 100644 --- a/src/swift/Queue.swift +++ b/src/swift/Queue.swift @@ -181,10 +181,15 @@ public extension DispatchQueue { flags: DispatchWorkItemFlags = [], execute work: @escaping @convention(block) () -> Void) { - if group == nil && qos == .unspecified && flags.isEmpty { + if group == nil && qos == .unspecified { // Fast-path route for the most common API usage - CDispatch.dispatch_async(self.__wrapped, work) - return + if flags.isEmpty { + CDispatch.dispatch_async(self.__wrapped, work) + return + } else if flags == .barrier { + CDispatch.dispatch_barrier_async(self.__wrapped, work) + return + } } var block: @convention(block) () -> Void = work