Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. /**
  2. * Grabs a lock and ensures mutual exclusion while calling `closure`
  3. * Example:
  4. * synced(self) {
  5. * // Code
  6. * }
  7. */
  8. func synced(lock: AnyObject, closure: () -> ()) {
  9. objc_sync_enter(lock)
  10. closure()
  11. objc_sync_exit(lock)
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement