dispatch_semaphore是GCD中常见的同步方式, 相关方法有三个: dispatch_semaphore_create, dispatch_semaphore_wait, dispatch_semaphore_signal.
dispatch_semaphore的使用方式
// will barrier the UI.
let signal: dispatch_semaphore_t = dispatch_semaphore_create(0)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
print("execution inside the block ...")
sleep(10)
dispatch_semaph