swift mutual exclusion
concurrency – What is the Swift equivalent to Objective-C’s "@synchronized"? – Stack Overflow
Grabs a lock and ensures mutual exclusion in swift · GitHub
Snip2Code – Grabs a lock and ensures mutual exclusion in swift
后来用的是:
func synced(lock: AnyObject, closure: () -> ()) { objc_sync_enter(lock) closure() objc_sync_exit(lock) } |
调用方式:
synced(self) { println("This is a synchronized closure") } |
转载请注明:在路上 » 【已解决】swift中的同步和互斥