Last active
October 19, 2015 14:06
-
-
Save mxl/dc501fd93074dda110ff to your computer and use it in GitHub Desktop.
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
import Foundation | |
func testFunction(completion: () -> ()) { | |
dispatch_async(dispatch_get_main_queue()) { | |
completion() | |
} | |
} | |
func testSemaphore() { | |
let semaphore = dispatch_semaphore_create(0) | |
testFunction { | |
dispatch_semaphore_signal(semaphore) | |
} | |
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) | |
} | |
print("1") | |
testSemaphore() | |
print("2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment