M3D-Engine let you split parts of your game logic into tasks and schedule them to run at different intervals. This Manager is the cornerstone of M3D-Engine’s event-driven design.
Tasks are defined as an execution block and a set of bound variables, the task context. They can have optional completion functions associated to them, and can either be synchronous or asynchronous, depending on your needs.
– Synchronous tasks
They are scheduled to run from the game thread, and are best suited for inexpensive and time dependent updates. These tasks are designed to run every frame and are used as such in the internal parts of the game engine, but they can still be scheduled to run at a certain time interval.
– Asynchronous tasks
They are scheduled to run in M3D-Engine’s thread pool, and encapsulate all the locking mechanisms needed for concurrent execution. In that case, completion functions for asynchronous tasks are executed in the game thread.
The Task Manager offers a third type of task : BlockingTasks. They serve the unique purpose of calling into the engine’s main thread and returning to the calling thread. These tasks are not meant to be used by the engine and game libraries, and their use is restricted to the wrappers.