Is cocos2d isTouchEnabled flag thread safe ? I want to set this flag in different thread .
If not can I use boost::mutex to guard it before access it ?
If not what objective-c class should I use to guard this ?
Many thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The
isTouchEnabledproperty is not thread safe. In fact, (almost) all properties of Cocos2D classes use the nonatomic property keyword to remove locks in favor of increasing the performance of property access.But it makes no difference if you ensure that you are changing that particular property only from a particular thread.
The Objective-C pendant for mutex locks is NSLock respectively @synchronized.