SDL_DelayNS(3)

πŸ’– SDL_DelayNS(3) πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_DelayNS β€” she naps, but like, in nanoseconds. iconic behavior honestly 🫢


✨ NAME ✨

SDL_DelayNS β€” wait a specified number of nanoseconds before returning. yes, nanoseconds. she's precise like that πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_timer.h>

void SDL_DelayNS(Uint64 ns);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. this function waits a specified number of nanoseconds before it returns. that's it, that's the whole vibe. ✨

but here's the tea, and it's important: she waits at least the specified time, but possibly longer due to OS scheduling. so if you're out here expecting exactly that many nanoseconds, no cap, that's not what's happening β€” the OS is doing its own thing and your little nap might run long. not her fault, it's giving "scheduling," iykyk 😭


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • ns β€” the number of nanoseconds to delay. that's your sleepytime number, bestie. πŸŒ™

πŸ‘‘ THREAD SAFETY πŸ‘‘

It is safe to call this function from any thread. fr fr. every thread gets to nap, no gatekeeping πŸ’œ


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older... girl. upgrade. πŸ™ˆ


⭐ SEE ALSO ⭐


lowkey reminder: "at least" is the whole point. don't come for her when the timing drifts. πŸ’€

and that's the page!! brought to you by the lovely humans at Simple Directmedia Layer, running SDL 3.4.18, and this little love letter to nanoseconds is dated SDL_DelayNS(3). slay, go take a nap, you deserve it πŸ§šπŸ’–

πŸ“¦ where this page comes from