AI-generated Key Takeaways
-
SbOnceensures a specific initialization routine (init_routine) is executed only once per process in a thread-safe manner. -
SbOnceControlis an opaque handle used bySbOnceto track whether the initialization has already occurred. -
SbOnceInitRoutineis a function pointer type that defines the signature of the initialization function. -
The
SbOncefunction returnstrueif theinit_routinewas executed or had already been executed, and it returnsfalseif the parameters provided were invalid.
Onces represent initializations that should only ever happen once per process, in a thread-safe way.
Macros
SB_ONCE_MAX_SIZE
Max size of the SbOnceControl type.
Typedefs
SbOnceControl
An opaque handle to a once control type with reserved memory buffer of size SB_ONCE_MAX_SIZE and aligned at void pointer type.
Definition
typedef union SbOnceControl SbOnceControl
SbOnceInitRoutine
Function pointer type for methods that can be called via the SbOnce() system.
Definition
typedef void(* SbOnceInitRoutine) (void)
Functions
SbOnce
Thread-safely runs init_routine only once.
If this
once_controlhas not run a function yet, this function runsinit_routinein a thread-safe way and then returnstrue.If SbOnce() was called with
once_controlbefore, the function returnstrueimmediately.If
once_controlorinit_routineis invalid, the function returnsfalse.
Declaration
bool SbOnce(SbOnceControl *once_control, SbOnceInitRoutine init_routine)