Created
March 8, 2017 02:42
-
-
Save onevcat/f965be103570a5e6f44149e08e905a3c to your computer and use it in GitHub Desktop.
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
func waitUntil(_ done: @escaping (@escaping () -> Void) -> Void) { | |
var completed: UInt32 = 0 | |
DispatchQueue.main.async { | |
done { OSAtomicOr32Barrier(1, &completed) } | |
} | |
while completed == 0 { | |
RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.01)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment