Created
April 27, 2022 16:29
-
-
Save EricRabil/10ad56fb02315c751fe32c8f2f7f4500 to your computer and use it in GitHub Desktop.
Get current dispatch queue in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DispatchQueue { | |
private static let dispatch_get_current_queue = dlsym(dlopen(nil, RTLD_GLOBAL), "dispatch_get_current_queue") | |
static var current: DispatchQueue { | |
dispatch_get_current_queue.map { | |
unsafeBitCast($0, to: (@convention(c) () -> Unmanaged<DispatchQueue>).self)().takeUnretainedValue() | |
} ?? .global(qos: .background) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works, Thanks a lot!