1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// // SynchronizedClosure.swift // DocsSDK // // Created by zenghao on 2018/8/19. // import Foundation let sema = DispatchSemaphore(value: 1) func synchronized(_ closure: () -> ()) { sema.wait() closure() sema.signal() }