SDL_InitState

Struct SDL_InitState 

Source
#[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_void

Trait Implementations§

Source§

impl Debug for SDL_InitState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SDL_InitState

Source§

fn default() -> Self

Initialize all fields to zero

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.