Facts of my program
task_scheduler
that runs in its own thread, in which you can submit lightweight tasks. Let's call it task_scheduler-thread.task_scheduler
thread. Let's call it task_scheduler-tick-callback.What I want to do
I want to load a sprite when task_scheduler-tick-callback is emitted, but I cannot do it from that thread, so I will have to submit some kind of work to be performed by cocos2d-x thread.
Problem
Any patterns?
EDIT: Idea -> any callback function called for each loop iteration in cocos2d-x? Does that exist? I could integrate the call to my work piece like that.
Use this to execute your code in main thread:
Director::getInstance()->getScheduler()->performFunctionInCocosThread([]{
// your code
});