Last active
August 29, 2015 14:02
-
-
Save Kaelten/7914a8128eca45f081b3 to your computer and use it in GitHub Desktop.
Simple Swift @synchronized Helper
This file contains 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
// A simple replacement for Obj-C's @synchronized keyword, currently seems to cause compiler error if lock is an object array. | |
func synced(lock: AnyObject, closure: () -> ()) { | |
objc_sync_enter(lock) | |
closure() | |
objc_sync_exit(lock) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment