Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

After tinkering a bit with cocos2d, I discovered that there is no classic game loop and everything is more-or-less event driven. I guess I can wrap my head around that, no problem.

But I cannot find anything about thread safety. Say, I schedule something to occur every two seconds, which Thread will run the code? Given that I cannot find anything about that, I guess there is just one Cocos2d Thread and everything will be fine.

Nevertheless, this implicit assumption does not give me a good feeling. Knowing is better than guessing. ;-)

Can anyone shed some light onto that topic?

share|improve this question

1 Answer 1

as much as I can remember, there is no built-in threads in cocos2d. as you said everything is event driven but, events are queued, and run once at a time. so you don't need to worry about the thread safety at all, just keep in mind that some when you schedule two different events, they might not be run in same order as you scheduled them. but I think the priority option will solve that issue events with lower priority runs first.

share|improve this answer
    
This is what I assumed, but is there any documentation about that? Thanks for you answer, tho! :) –  Malax Apr 13 '12 at 10:01
    
just imagine if cocos2d itself was using threads, why should they tell developers to use external pthread to do their threading needs? –  Ali.S Apr 13 '12 at 10:05
    
Don't get me wrong, I think you're totally right. :-) I just would love to have a clear statement in the documentation about this. :-) –  Malax Apr 13 '12 at 11:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.