0
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ This is what I assumed, but is there any documentation about that? Thanks for you answer, tho! :) \$\endgroup\$
    – Malax
    Apr 13, 2012 at 10:01
  • \$\begingroup\$ just imagine if cocos2d itself was using threads, why should they tell developers to use external pthread to do their threading needs? \$\endgroup\$
    – Ali1S232
    Apr 13, 2012 at 10:05
  • \$\begingroup\$ 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. :-) \$\endgroup\$
    – Malax
    Apr 13, 2012 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .