sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Atomic.Safe

Synopsis

Documentation

sDL_TryLockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO CBool 

Try to lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Returns
true if the lock succeeded, false if the lock is already held.
Thread safety
It is safe to call this function from any thread.
See also
sDL_LockSpinlock, sDL_UnlockSpinlock
C declaration
SDL_TryLockSpinlock, defined at SDL3/SDL_atomic.h 100:34

Since: 3.2.0

sDL_LockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
sDL_TryLockSpinlock, sDL_UnlockSpinlock
C declaration
SDL_LockSpinlock, defined at SDL3/SDL_atomic.h 117:34

Since: 3.2.0

sDL_UnlockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Unlock a spin lock by setting it to 0.

Always returns immediately.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
sDL_LockSpinlock, sDL_TryLockSpinlock
C declaration
SDL_UnlockSpinlock, defined at SDL3/SDL_atomic.h 136:34

Since: 3.2.0

sDL_MemoryBarrierReleaseFunction :: IO () Source #

Insert a memory release barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierRelease
C declaration
SDL_MemoryBarrierReleaseFunction, defined at SDL3/SDL_atomic.h 195:34

Since: 3.2.0

sDL_MemoryBarrierAcquireFunction :: IO () Source #

Insert a memory acquire barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierAcquire
C declaration
SDL_MemoryBarrierAcquireFunction, defined at SDL3/SDL_atomic.h 215:34

Since: 3.2.0

sDL_CompareAndSwapAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> CInt
oldval
the old value.
-> CInt
newval
the new value.
-> IO CBool 

Set an atomic variable to a new value if it is currently an old value.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetAtomicInt, sDL_SetAtomicInt
C declaration
SDL_CompareAndSwapAtomicInt, defined at SDL3/SDL_atomic.h 425:34

Since: 3.2.0

sDL_SetAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> CInt
v
the desired value.
-> IO CInt 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetAtomicInt
C declaration
SDL_SetAtomicInt, defined at SDL3/SDL_atomic.h 445:33

Since: 3.2.0

sDL_GetAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable.
-> IO CInt 

Get the value of an atomic variable.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
sDL_SetAtomicInt
C declaration
SDL_GetAtomicInt, defined at SDL3/SDL_atomic.h 462:33

Since: 3.2.0

sDL_AddAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> CInt
v
the desired value to add.
-> IO CInt 

Add to an atomic variable.

This function also acts as a full memory barrier.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
SDL_AtomicDecRef, SDL_AtomicIncRef
C declaration
SDL_AddAtomicInt, defined at SDL3/SDL_atomic.h 483:33

Since: 3.2.0

sDL_CompareAndSwapAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Uint32
oldval
the old value.
-> Uint32
newval
the new value.
-> IO CBool 

Set an atomic variable to a new value if it is currently an old value.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetAtomicU32, sDL_SetAtomicU32
C declaration
SDL_CompareAndSwapAtomicU32, defined at SDL3/SDL_atomic.h 570:34

Since: 3.2.0

sDL_SetAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Uint32
v
the desired value.
-> IO Uint32 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetAtomicU32
C declaration
SDL_SetAtomicU32, defined at SDL3/SDL_atomic.h 590:36

Since: 3.2.0

sDL_GetAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable.
-> IO Uint32 

Get the value of an atomic variable.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
sDL_SetAtomicU32
C declaration
SDL_GetAtomicU32, defined at SDL3/SDL_atomic.h 607:36

Since: 3.2.0

sDL_AddAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> CInt
v
the desired value to add or subtract.
-> IO Uint32 

Add to an atomic variable.

This function also acts as a full memory barrier.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_AddAtomicU32, defined at SDL3/SDL_atomic.h 625:36

Since: 3.4.0

sDL_CompareAndSwapAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
oldval
the old pointer value.
-> Ptr Void
newval
the new pointer value.
-> IO CBool 

Set a pointer to a new value if it is currently an old value.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
true if the pointer was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CompareAndSwapAtomicInt, sDL_GetAtomicPointer, sDL_SetAtomicPointer
C declaration
SDL_CompareAndSwapAtomicPointer, defined at SDL3/SDL_atomic.h 646:34

Since: 3.2.0

sDL_SetAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
v
the desired pointer value.
-> IO (Ptr Void) 

Set a pointer to a value atomically.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the previous value of the pointer.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CompareAndSwapAtomicPointer, sDL_GetAtomicPointer
C declaration
SDL_SetAtomicPointer, defined at SDL3/SDL_atomic.h 665:36

Since: 3.2.0

sDL_GetAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> IO (Ptr Void) 

Get the value of a pointer atomically.

Note: If you don't know what this function is for, you shouldn't use it!

Returns
the current value of a pointer.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CompareAndSwapAtomicPointer, sDL_SetAtomicPointer
C declaration
SDL_GetAtomicPointer, defined at SDL3/SDL_atomic.h 683:36

Since: 3.2.0