Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 19, 2020 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/e5b7245b40e354fc2bf2fe8e873ca55b to your computer and use it in GitHub Desktop.
Save stevencurtis/e5b7245b40e354fc2bf2fe8e873ca55b to your computer and use it in GitHub Desktop.
performwork
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