I am trying to implementing multi-threaded game loop in iOS. (Actually, two thread - Render and Update)

This is my structure.

  1. Update Loop

    • Has logic and at the end of loop, save update state. (Basically copy buffer for Render)
  2. Render Loop

    • Using CADsiplayLink
    • It is on Main
    • Everytime, it triggers method, get the state, and draw.

I am seeing some stuttering, and I am thinking render loop is just faster than update loop, and also inconsistent "Render" call, something like this:

  • Update #1 -> Render #1
  • Update #2 -> Render #1
  • Update #2 -> Render #2

How can I synchronize this?

I heard that Render thread should be not on Main Thread, and I am using CADisplayLink with default setting. (Call MainLoop); is it running on Main thread? If running on different thread, is better, can I get some suggestions working with CADisplayLink? It could be that I just lack some understanding about CADisplayLink.

Is my current structure adequate? Could it be improved?

  • \$\begingroup\$ what's the point of multithreading here? After all the render method has to wait for update every frame, so there won't be any benefits from running them on separate threads. Instead multithread algorithms such as game logic or draw order sorting or preparing vertex buffers. \$\endgroup\$ – LearnCocos2D Feb 21 '14 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.