Last active
December 7, 2017 15:05
-
-
Save berikv/a4539e5295681a8eb005130f2a16c576 to your computer and use it in GitHub Desktop.
Stop the current thread for a specified period using a semaphore
This file contains hidden or 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 deadlineTime = DispatchTime.now() + .seconds(100) | |
| let semaphore = DispatchSemaphore(value: 1) | |
| DispatchQueue.global().asyncAfter(deadline: deadlineTime) { | |
| semaphore.signal() | |
| } | |
| semaphore.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment