SDL3pp
A slim C++ wrapper for SDL3
|
A structure used for thread-safe initialization and shutdown. More...
Public Member Functions | |
constexpr | InitState () |
Constructor. | |
bool | ShouldInit () |
Return whether initialization should be done. | |
bool | ShouldQuit () |
Return whether cleanup should be done. | |
void | SetInitialized (bool initialized) |
Finish an initialization state transition. | |
Here is an example of using this:
Note that this doesn't protect any resources created during initialization, or guarantee that nobody is using those resources during cleanup. You should use other mechanisms to protect those, if that's a concern for your code.
|
inline |
This function sets the status of the passed in state to INIT_STATUS_INITIALIZED
or INIT_STATUS_UNINITIALIZED
and allows any threads waiting for the status to proceed.
initialized | the new initialization state. |
|
inline |
This function checks the passed in state and if initialization should be done, sets the status to INIT_STATUS_INITIALIZING
and returns true. If another thread is already modifying this state, it will wait until that's done before returning.
If this function returns true, the calling code must call InitState.SetInitialized() to complete the initialization.
|
inline |
This function checks the passed in state and if cleanup should be done, sets the status to INIT_STATUS_UNINITIALIZING
and returns true.
If this function returns true, the calling code must call InitState.SetInitialized() to complete the cleanup.