rest(3alleg4)

πŸ’€ rest β€” the "bestie please chill" function

okay so, we're in the Allegro game programming library, manual section 3, and today's main character is rest. she's the one who tells your program to take a lil nap. ✨


🌸 SYNOPSIS

#include <allegro.h>

void rest(unsigned int time);

πŸ¦‹ DESCRIPTION

So rest waits for however many milliseconds you hand it in time. That's it. That's the whole vibe. She waits, you vibe. πŸ’…

Now here's the tea πŸ«– β€” if you pass 0 as the parameter, she does not wait at all, she just yields. And lowkey that's so useful?? It's literally how you "play nice" with other processes on the system. Sharing is caring, bestie. 🫢

Any other value will cause CPU time to be dropped on most platforms. And that's a good thing, fr fr β€” it looks better to users, plus it does cute little side quests like saving battery power and making fans less noisy. 🌈 Your laptop's fan will literally thank you.

⚠️ BUT. Big but. Calling this inside your active game loop is a bad idea. Like, genuinely. The way that you never know when the OS will give you the CPU back 😭 β€” so you could end up missing the vertical retrace and skipping frames. That's giving dropped frames energy and nobody wants that. πŸ™ˆ
✨ On the flip side tho β€” on multitasking operating systems, it is good form to give up the CPU for a while if you will not be using it. So. Read the room. iykyk. πŸ’–

πŸ‘‘ SEE ALSO


Allegro version 4.4.3 πŸŽ€ β€” and that's the whole page, rest(3alleg4), periodt. go take a nap, you earned it. πŸ’œ