sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Mutex

Synopsis

Documentation

data SDL_Mutex Source #

A means to serialize access to a resource between threads.

Mutexes (short for "mutual exclusion") are a synchronization primitive that allows exactly one thread to proceed at a time.

Wikipedia has a thorough explanation of the concept:

https://en.wikipedia.org/wiki/Mutex

C declaration
struct SDL_Mutex, defined at SDL3/SDL_mutex.h 296:16

Since: 3.2.0

data SDL_RWLock Source #

A mutex that allows read-only threads to run in parallel.

A rwlock is roughly the same concept as SDL_Mutex, but allows threads that request read-only access to all hold the lock at the same time. If a thread requests write access, it will block until all read-only threads have released the lock, and no one else can hold the thread (for reading or writing) at the same time as the writing thread.

This can be more efficient in cases where several threads need to access data frequently, but changes to that data are rare.

There are other rules that apply to rwlocks that don't apply to mutexes, about how threads are scheduled and when they can be recursively locked. These are documented in the other rwlock functions.

C declaration
struct SDL_RWLock, defined at SDL3/SDL_mutex.h 438:16

Since: 3.2.0

data SDL_Semaphore Source #

A means to manage access to a resource, by count, between threads.

Semaphores (specifically, "counting semaphores"), let X number of threads request access at the same time, each thread granted access decrementing a counter. When the counter reaches zero, future requests block until a prior thread releases their request, incrementing the counter again.

Wikipedia has a thorough explanation of the concept:

https://en.wikipedia.org/wiki/Semaphore_(programming))

C declaration
struct SDL_Semaphore, defined at SDL3/SDL_mutex.h 684:16

Since: 3.2.0

data SDL_Condition Source #

A means to block multiple threads until a condition is satisfied.

Condition variables, paired with an SDL_Mutex, let an app halt multiple threads until a condition has occurred, at which time the app can release one or all waiting threads.

Wikipedia has a thorough explanation of the concept:

https://en.wikipedia.org/wiki/Condition_variable

C declaration
struct SDL_Condition, defined at SDL3/SDL_mutex.h 841:16

Since: 3.2.0

newtype SDL_InitStatus Source #

The current status of an SDL_InitState structure.

C declaration
enum SDL_InitStatus, defined at SDL3/SDL_mutex.h 975:14

Since: 3.2.0

Constructors

SDL_InitStatus 

Fields

Instances

Instances details
Storable SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Generic SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type Rep SDL_InitStatus 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type Rep SDL_InitStatus = D1 ('MetaData "SDL_InitStatus" "SDL3.Sys.Bindgen.Mutex" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_InitStatus" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUInt)))
Read SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Show SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Eq SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Ord SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Prim SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

CEnum SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type CEnumZ SDL_InitStatus 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

SequentialCEnum SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

HasFFIType SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type FFIType SDL_InitStatus 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

ReadRaw SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

StaticSize SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

WriteRaw SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

HasCField SDL_InitStatus "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type CFieldType SDL_InitStatus "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

offset# :: Proxy# SDL_InitStatus -> Proxy# "unwrap" -> Int #

ty ~ CUInt => HasField "unwrap" SDL_InitStatus ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

hasField :: SDL_InitStatus -> (ty -> SDL_InitStatus, ty) #

ty ~ CUInt => HasField "unwrap" (Ptr SDL_InitStatus) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

getField :: Ptr SDL_InitStatus -> Ptr ty #

type Rep SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type Rep SDL_InitStatus = D1 ('MetaData "SDL_InitStatus" "SDL3.Sys.Bindgen.Mutex" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_InitStatus" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUInt)))
type CEnumZ SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type FFIType SDL_InitStatus Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type CFieldType SDL_InitStatus "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

pattern SDL_INIT_STATUS_UNINITIALIZED :: SDL_InitStatus Source #

C declaration
SDL_INIT_STATUS_UNINITIALIZED, defined at SDL3/SDL_mutex.h 977:5

pattern SDL_INIT_STATUS_INITIALIZING :: SDL_InitStatus Source #

C declaration
SDL_INIT_STATUS_INITIALIZING, defined at SDL3/SDL_mutex.h 978:5

pattern SDL_INIT_STATUS_INITIALIZED :: SDL_InitStatus Source #

C declaration
SDL_INIT_STATUS_INITIALIZED, defined at SDL3/SDL_mutex.h 979:5

pattern SDL_INIT_STATUS_UNINITIALIZING :: SDL_InitStatus Source #

C declaration
SDL_INIT_STATUS_UNINITIALIZING, defined at SDL3/SDL_mutex.h 980:5

data SDL_InitState Source #

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.

C declaration
struct SDL_InitState, defined at SDL3/SDL_mutex.h 1039:16

Since: 3.2.0

Constructors

SDL_InitState 

Fields

Instances

Instances details
Storable SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Generic SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type Rep SDL_InitState 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type Rep SDL_InitState = D1 ('MetaData "SDL_InitState" "SDL3.Sys.Bindgen.Mutex" "sdl3-bindgen-sys-0.0.1.0-inplace" 'False) (C1 ('MetaCons "SDL_InitState" 'PrefixI 'True) (S1 ('MetaSel ('Just "status") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SDL_AtomicInt) :*: (S1 ('MetaSel ('Just "thread") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SDL_ThreadID) :*: S1 ('MetaSel ('Just "reserved") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Ptr Void)))))
Show SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Eq SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

ReadRaw SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

StaticSize SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

WriteRaw SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

IsStruct SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

zero :: SDL_InitState #

HasCField SDL_InitState "reserved" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type CFieldType SDL_InitState "reserved" 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type CFieldType SDL_InitState "reserved" = Ptr Void

Methods

offset# :: Proxy# SDL_InitState -> Proxy# "reserved" -> Int #

HasCField SDL_InitState "status" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type CFieldType SDL_InitState "status" 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

offset# :: Proxy# SDL_InitState -> Proxy# "status" -> Int #

HasCField SDL_InitState "thread" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Associated Types

type CFieldType SDL_InitState "thread" 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

offset# :: Proxy# SDL_InitState -> Proxy# "thread" -> Int #

ty ~ Ptr Void => HasField "reserved" SDL_InitState ty Source #
C declaration
reserved, defined at SDL3/SDL_mutex.h 1043:11
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

hasField :: SDL_InitState -> (ty -> SDL_InitState, ty) #

ty ~ SDL_AtomicInt => HasField "status" SDL_InitState ty Source #
C declaration
status, defined at SDL3/SDL_mutex.h 1041:19
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

hasField :: SDL_InitState -> (ty -> SDL_InitState, ty) #

ty ~ SDL_ThreadID => HasField "thread" SDL_InitState ty Source #
C declaration
thread, defined at SDL3/SDL_mutex.h 1042:18
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

hasField :: SDL_InitState -> (ty -> SDL_InitState, ty) #

ty ~ Ptr Void => HasField "reserved" (Ptr SDL_InitState) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

getField :: Ptr SDL_InitState -> Ptr ty #

ty ~ SDL_AtomicInt => HasField "status" (Ptr SDL_InitState) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

getField :: Ptr SDL_InitState -> Ptr ty #

ty ~ SDL_ThreadID => HasField "thread" (Ptr SDL_InitState) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

Methods

getField :: Ptr SDL_InitState -> Ptr ty #

type Rep SDL_InitState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type Rep SDL_InitState = D1 ('MetaData "SDL_InitState" "SDL3.Sys.Bindgen.Mutex" "sdl3-bindgen-sys-0.0.1.0-inplace" 'False) (C1 ('MetaCons "SDL_InitState" 'PrefixI 'True) (S1 ('MetaSel ('Just "status") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SDL_AtomicInt) :*: (S1 ('MetaSel ('Just "thread") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SDL_ThreadID) :*: S1 ('MetaSel ('Just "reserved") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Ptr Void)))))
type CFieldType SDL_InitState "reserved" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type CFieldType SDL_InitState "reserved" = Ptr Void
type CFieldType SDL_InitState "status" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex

type CFieldType SDL_InitState "thread" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Mutex