Every game engine today should have a job system that harvests the power of the available CPU cores. Additionally, C++20 has introduced co-routines, which can schedule other tasks and suspend until these tasks have finished. Due to this suspension, the thread the co-routine is running on is free to serve other jobs.
Using co-routines in a job system results in easy to read code, local variables do not go out of scope until the co-routine returns.
However, there is a price to pay. Co-routines demand to use their own machinery for suspension and synchronizing them with other co-routines. Mixing in functions, lambdas or functors that do not have access to this machinery proves to be a demanding task, especially if they should interact and synchronize with co-routines.
This talk presents the Vienna Game Job System (VGJS), a C++20 based job system that seamlessly combines co-routines with functions, lamdas and functors. Co-routines can synchronize with functions, and vice-versa. This way, programmers can always choose which form of job is appropriate - either create a co-routine (which incurs some overhead due to allocations from the heap and the co-routine machinery), or run a function, a functor, etc., with generally better performance.
Additionally, VGJS allows to create tagged jobs to be run later, e.g., if a game in the game loop goes sequentially through phases, and specific jobs should be run in them. VGJS also allows for collecting performance trace files to be visualized in Chrome, and supports memory resources to be used for its allocations.
The talk will also show performance differences between co-routines, functions, and fibers (co-routines that do not return).
ALL TALK SESSIONS CAN BE ACCESSED FROM THE MAIN LOBBY:
https://cppcon.digital-medium.co.uk/