DEV Community


Setting Up A Job System

the_wooden_h profile image Wooden H Studio ・2 min read

What's the problem?

Long story short; we have too much going on. Long story long; games require a lot of computing power, everything you see on screen is the visual representation of a bunch of math, and just like the rest of us, CPU's tend to slow down when exposed to too much math.

Whats the Solution?

Multi-threading! instead of forcing a single CPU core to do all the math, we're going to have to delegate it to other cores. That'll make it so that our main thread can really chill out and find itself while it draws all the pretty shapes that we end up seeing in the game, all while the other lesser liked threads gruel away on boring math (don't worry they like it).

Whats the better solution?

A Job system! A job system is going to let us dynamically start new threads as we need them. A video game isn't going to be mathematically intensive every single second. Sometimes you get some chill moments that let both you and the CPU relax and have a nice sip of tea (please don't pour tea into your CPU), and during these times, you don't really need a lot of threads to render everything. Other times you have way too much happened on-screen, and you feel like you need to step away so that you can call a friend and have them assure you that there are enough threads to handle all that math! What I'm trying to say is that a Job system is a way to queue up a bunch of function pointers that you send off into their own threads so that they can do their jobs in peace. This system allows us to really up the amount of math the CPU can do at once, this way the game doesn't have to wait for the Physics to calculate how far the character flies away so that it can make sure the sky is still blue.

By Ahmed Fayez

Discussion (0)

Forem Open with the Forem app