#[repr(C)]pub struct SDL_InitState {
pub status: SDL_AtomicInt,
pub thread: SDL_ThreadID,
pub reserved: *mut c_void,
}Expand description
A structure used for thread-safe initialization and shutdown.
Here is an example of using this:
static SDL_InitState init;
bool InitSystem(void)
{
if (!SDL_ShouldInit(&init)) {
// The system is initialized
return true;
}
// At this point, you should not leave this function without calling SDL_SetInitialized()
bool initialized = DoInitTasks();
SDL_SetInitialized(&init, initialized);
return initialized;
}
bool UseSubsystem(void)
{
if (SDL_ShouldInit(&init)) {
// Error, the subsystem isn't initialized
SDL_SetInitialized(&init, false);
return false;
}
// Do work using the initialized subsystem
return true;
}
void QuitSystem(void)
{
if (!SDL_ShouldQuit(&init)) {
// The system is not initialized
return;
}
// At this point, you should not leave this function without calling SDL_SetInitialized()
DoQuitTasks();
SDL_SetInitialized(&init, false);
}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.
§Availability
This struct is available since SDL 3.2.0.
Fields§
§status: SDL_AtomicInt§thread: SDL_ThreadID§reserved: *mut c_voidTrait Implementations§
Source§impl Debug for SDL_InitState
impl Debug for SDL_InitState
Auto Trait Implementations§
impl Freeze for SDL_InitState
impl RefUnwindSafe for SDL_InitState
impl !Send for SDL_InitState
impl !Sync for SDL_InitState
impl Unpin for SDL_InitState
impl UnwindSafe for SDL_InitState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more