Background code execution?

I have a rather large database I need to query every once in a while and some of the queries can take a bit of time to execute (100ms+), and noticeably pause the game while the query executes.

Is there a way to relegate this code execution to the background, keeping the game running smoothly? I’d rather avoid having any loading screens. I don’t need the results right away, just down the line.

I thought there was some kind of async example in the cpp-tests app, but I can’t find it, and I can only find how to load sprites/textures asyncronously on Google.

You can use c++ pthreads.

EDIT: There are some limitations that you can find out about here, but I don’t think they represent a big problem.

Looks like just what I need, thank you!

It’s std::thread, now. See:
http://discuss.cocos2d-x.org/t/pthread-h-missing-include-file/35610

1 Like