Reputation: 3443
I'm working on a project to handle state machine changes that need to be obeyed between numerous thread but just stumbled onto they are nonatomic by default. Is there a way to make Swift properties thread-safe or atomic at the time of Xcode6-Beta4? Thanks in advance.
Upvotes: 17
Views: 9966
Reputation: 2327
I think Alexander W has the right idea, but I would advise synchronizing on self
as a general rule. Perhaps the suggestion I posted here may help:
Upvotes: 2
Reputation: 65
You can implement your Getters Setters on thread-safe properties with use of dispatch_semaphore_t, NSLock or pthread_mutex_t, or similiar stuff.
Currently, there are no attributes, which define some behaviour, like atomic/nonatomic quialifers of Obj-C
Upvotes: 1