Created
June 19, 2020 16:31
-
-
Save stevencurtis/e5b7245b40e354fc2bf2fe8e873ca55b to your computer and use it in GitHub Desktop.
performwork
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
let semaphore = DispatchSemaphore(value: 1) | |
func performWork(queue: DispatchQueue) { | |
queue.async { | |
semaphore.wait() | |
for i in 0...10 { | |
print (i, queue.label) | |
semaphore.signal() | |
} | |
} | |
} | |
performWork(queue: userPriority) | |
performWork(queue: defaultPriority) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment