| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Bindgen.Timer
Description
SDL provides time management functionality. It is useful for dealing with (usually) small durations of time.
This is not to be confused with calendar time management, which is provided by CategoryTime.
This category covers measuring time elapsed (SDL_GetTicks(), SDL_GetPerformanceCounter()), putting a thread to sleep for a certain amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing a callback function after a certain amount of time has elapsed (SDL_AddTimer(), etc).
There are also useful macros to convert between time units, like SDL_SECONDS_TO_NS() and such. Number of milliseconds in a second.
This is always 1000.
Since: 3.2.0
Synopsis
- sDL_MS_PER_SECOND :: CInt
- sDL_US_PER_SECOND :: CInt
- sDL_NS_PER_SECOND :: CLLong
- sDL_NS_PER_MS :: CInt
- sDL_NS_PER_US :: CInt
- sDL_NS_TO_SECONDS :: Div a0 CLLong => a0 -> DivRes a0 CLLong
- sDL_NS_TO_MS :: Div a0 CInt => a0 -> DivRes a0 CInt
- sDL_NS_TO_US :: Div a0 CInt => a0 -> DivRes a0 CInt
- newtype SDL_TimerID = SDL_TimerID {}
- newtype SDL_TimerCallback_Aux = SDL_TimerCallback_Aux {}
- newtype SDL_TimerCallback = SDL_TimerCallback {}
- newtype SDL_NSTimerCallback_Aux = SDL_NSTimerCallback_Aux {}
- newtype SDL_NSTimerCallback = SDL_NSTimerCallback {}
Documentation
sDL_MS_PER_SECOND :: CInt Source #
- C declaration
macro SDL_MS_PER_SECOND, defined atSDL3/SDL_timer.h 62:9
sDL_US_PER_SECOND :: CInt Source #
Number of microseconds in a second.
This is always 1000000.
- C declaration
macro SDL_US_PER_SECOND, defined atSDL3/SDL_timer.h 71:9
Since: 3.2.0
sDL_NS_PER_SECOND :: CLLong Source #
Number of nanoseconds in a second.
This is always 1000000000.
- C declaration
macro SDL_NS_PER_SECOND, defined atSDL3/SDL_timer.h 80:9
Since: 3.2.0
sDL_NS_PER_MS :: CInt Source #
Number of nanoseconds in a millisecond.
This is always 1000000.
- C declaration
macro SDL_NS_PER_MS, defined atSDL3/SDL_timer.h 89:9
Since: 3.2.0
sDL_NS_PER_US :: CInt Source #
Number of nanoseconds in a microsecond.
This is always 1000.
- C declaration
macro SDL_NS_PER_US, defined atSDL3/SDL_timer.h 98:9
Since: 3.2.0
sDL_NS_TO_SECONDS :: Div a0 CLLong => a0 -> DivRes a0 CLLong Source #
Convert nanoseconds to seconds.
This performs a division, so the results can be dramatically different if NS is an integer or floating point value.
NS- the number of nanoseconds to convert.
- Returns
- NS, expressed in seconds.
- Thread safety
- It is safe to call this macro from any thread.
- C declaration
macro SDL_NS_TO_SECONDS, defined atSDL3/SDL_timer.h 127:9
Since: 3.2.0
sDL_NS_TO_MS :: Div a0 CInt => a0 -> DivRes a0 CInt Source #
Convert nanoseconds to milliseconds.
This performs a division, so the results can be dramatically different if NS is an integer or floating point value.
NS- the number of nanoseconds to convert.
- Returns
- NS, expressed in milliseconds.
- Thread safety
- It is safe to call this macro from any thread.
- C declaration
macro SDL_NS_TO_MS, defined atSDL3/SDL_timer.h 156:9
Since: 3.2.0
sDL_NS_TO_US :: Div a0 CInt => a0 -> DivRes a0 CInt Source #
Convert nanoseconds to microseconds.
This performs a division, so the results can be dramatically different if NS is an integer or floating point value.
NS- the number of nanoseconds to convert.
- Returns
- NS, expressed in microseconds.
- Thread safety
- It is safe to call this macro from any thread.
- C declaration
macro SDL_NS_TO_US, defined atSDL3/SDL_timer.h 185:9
Since: 3.2.0
newtype SDL_TimerID Source #
Definition of the timer ID type.
- C declaration
SDL_TimerID, defined atSDL3/SDL_timer.h 306:16
Since: 3.2.0
Constructors
| SDL_TimerID | |
Instances
newtype SDL_TimerCallback_Aux Source #
Auxiliary type used by SDL_TimerCallback
- C declaration
SDL_TimerCallback, defined atSDL3/SDL_timer.h 332:26
Constructors
| SDL_TimerCallback_Aux | |
Instances
| Generic SDL_TimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
Methods from :: SDL_TimerCallback_Aux -> Rep SDL_TimerCallback_Aux x # to :: Rep SDL_TimerCallback_Aux x -> SDL_TimerCallback_Aux # | |||||
| FromFunPtr SDL_TimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods fromFunPtr :: FunPtr SDL_TimerCallback_Aux -> SDL_TimerCallback_Aux # | |||||
| ToFunPtr SDL_TimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods toFunPtr :: SDL_TimerCallback_Aux -> IO (FunPtr SDL_TimerCallback_Aux) # | |||||
| HasCField SDL_TimerCallback_Aux "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
| |||||
| ty ~ (Ptr Void -> SDL_TimerID -> Uint32 -> IO Uint32) => HasField "unwrap" SDL_TimerCallback_Aux ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods hasField :: SDL_TimerCallback_Aux -> (ty -> SDL_TimerCallback_Aux, ty) # | |||||
| ty ~ (Ptr Void -> SDL_TimerID -> Uint32 -> IO Uint32) => HasField "unwrap" (Ptr SDL_TimerCallback_Aux) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods getField :: Ptr SDL_TimerCallback_Aux -> Ptr ty # | |||||
| type Rep SDL_TimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer type Rep SDL_TimerCallback_Aux = D1 ('MetaData "SDL_TimerCallback_Aux" "SDL3.Sys.Bindgen.Timer" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_TimerCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> SDL_TimerID -> Uint32 -> IO Uint32)))) | |||||
| type CFieldType SDL_TimerCallback_Aux "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||
newtype SDL_TimerCallback Source #
Function prototype for the millisecond timer callback function.
The callback function is passed the current timer interval and returns the next timer interval, in milliseconds. If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled. If the callback returns 0, the periodic alarm is canceled and will be removed.
userdata- an arbitrary pointer provided by the app through SDL_AddTimer, for its own use.
timerID- the current timer being processed.
interval- the current callback time interval.
- Returns
- the new callback time interval, or 0 to disable further runs of the callback.
- Thread safety
- SDL may call this callback at any time from a background thread; the application is responsible for locking resources the callback touches that need to be protected.
- See also
sDL_AddTimer- C declaration
SDL_TimerCallback, defined atSDL3/SDL_timer.h 332:26
Since: 3.2.0
Constructors
| SDL_TimerCallback | |
Fields | |
Instances
| Storable SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods sizeOf :: SDL_TimerCallback -> Int # alignment :: SDL_TimerCallback -> Int # peekElemOff :: Ptr SDL_TimerCallback -> Int -> IO SDL_TimerCallback # pokeElemOff :: Ptr SDL_TimerCallback -> Int -> SDL_TimerCallback -> IO () # peekByteOff :: Ptr b -> Int -> IO SDL_TimerCallback # pokeByteOff :: Ptr b -> Int -> SDL_TimerCallback -> IO () # peek :: Ptr SDL_TimerCallback -> IO SDL_TimerCallback # poke :: Ptr SDL_TimerCallback -> SDL_TimerCallback -> IO () # | |||||
| Generic SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
Methods from :: SDL_TimerCallback -> Rep SDL_TimerCallback x # to :: Rep SDL_TimerCallback x -> SDL_TimerCallback # | |||||
| Show SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods showsPrec :: Int -> SDL_TimerCallback -> ShowS # show :: SDL_TimerCallback -> String # showList :: [SDL_TimerCallback] -> ShowS # | |||||
| Eq SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods (==) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # (/=) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # | |||||
| Ord SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods compare :: SDL_TimerCallback -> SDL_TimerCallback -> Ordering # (<) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # (<=) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # (>) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # (>=) :: SDL_TimerCallback -> SDL_TimerCallback -> Bool # max :: SDL_TimerCallback -> SDL_TimerCallback -> SDL_TimerCallback # min :: SDL_TimerCallback -> SDL_TimerCallback -> SDL_TimerCallback # | |||||
| HasFFIType SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
Methods toFFIType :: SDL_TimerCallback -> FFIType SDL_TimerCallback # fromFFIType :: FFIType SDL_TimerCallback -> SDL_TimerCallback # | |||||
| ReadRaw SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods | |||||
| StaticSize SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods staticSizeOf :: Proxy SDL_TimerCallback -> Int # | |||||
| WriteRaw SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods writeRaw :: Ptr SDL_TimerCallback -> SDL_TimerCallback -> IO () # | |||||
| HasCField SDL_TimerCallback "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
| |||||
| ty ~ FunPtr SDL_TimerCallback_Aux => HasField "unwrap" SDL_TimerCallback ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods hasField :: SDL_TimerCallback -> (ty -> SDL_TimerCallback, ty) # | |||||
| ty ~ FunPtr SDL_TimerCallback_Aux => HasField "unwrap" (Ptr SDL_TimerCallback) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods getField :: Ptr SDL_TimerCallback -> Ptr ty # | |||||
| type Rep SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer type Rep SDL_TimerCallback = D1 ('MetaData "SDL_TimerCallback" "SDL3.Sys.Bindgen.Timer" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_TimerCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_TimerCallback_Aux)))) | |||||
| type FFIType SDL_TimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||
| type CFieldType SDL_TimerCallback "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||
newtype SDL_NSTimerCallback_Aux Source #
Auxiliary type used by SDL_NSTimerCallback
- C declaration
SDL_NSTimerCallback, defined atSDL3/SDL_timer.h 394:26
Constructors
| SDL_NSTimerCallback_Aux | |
Instances
| Generic SDL_NSTimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
Methods from :: SDL_NSTimerCallback_Aux -> Rep SDL_NSTimerCallback_Aux x # to :: Rep SDL_NSTimerCallback_Aux x -> SDL_NSTimerCallback_Aux # | |||||
| FromFunPtr SDL_NSTimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods fromFunPtr :: FunPtr SDL_NSTimerCallback_Aux -> SDL_NSTimerCallback_Aux # | |||||
| ToFunPtr SDL_NSTimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods toFunPtr :: SDL_NSTimerCallback_Aux -> IO (FunPtr SDL_NSTimerCallback_Aux) # | |||||
| HasCField SDL_NSTimerCallback_Aux "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
| |||||
| ty ~ (Ptr Void -> SDL_TimerID -> Uint64 -> IO Uint64) => HasField "unwrap" SDL_NSTimerCallback_Aux ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods hasField :: SDL_NSTimerCallback_Aux -> (ty -> SDL_NSTimerCallback_Aux, ty) # | |||||
| ty ~ (Ptr Void -> SDL_TimerID -> Uint64 -> IO Uint64) => HasField "unwrap" (Ptr SDL_NSTimerCallback_Aux) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods getField :: Ptr SDL_NSTimerCallback_Aux -> Ptr ty # | |||||
| type Rep SDL_NSTimerCallback_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer type Rep SDL_NSTimerCallback_Aux = D1 ('MetaData "SDL_NSTimerCallback_Aux" "SDL3.Sys.Bindgen.Timer" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_NSTimerCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> SDL_TimerID -> Uint64 -> IO Uint64)))) | |||||
| type CFieldType SDL_NSTimerCallback_Aux "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||
newtype SDL_NSTimerCallback Source #
Function prototype for the nanosecond timer callback function.
The callback function is passed the current timer interval and returns the next timer interval, in nanoseconds. If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled. If the callback returns 0, the periodic alarm is canceled and will be removed.
userdata- an arbitrary pointer provided by the app through SDL_AddTimer, for its own use.
timerID- the current timer being processed.
interval- the current callback time interval.
- Returns
- the new callback time interval, or 0 to disable further runs of the callback.
- Thread safety
- SDL may call this callback at any time from a background thread; the application is responsible for locking resources the callback touches that need to be protected.
- See also
sDL_AddTimerNS- C declaration
SDL_NSTimerCallback, defined atSDL3/SDL_timer.h 394:26
Since: 3.2.0
Constructors
| SDL_NSTimerCallback | |
Fields | |
Instances
| Storable SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods sizeOf :: SDL_NSTimerCallback -> Int # alignment :: SDL_NSTimerCallback -> Int # peekElemOff :: Ptr SDL_NSTimerCallback -> Int -> IO SDL_NSTimerCallback # pokeElemOff :: Ptr SDL_NSTimerCallback -> Int -> SDL_NSTimerCallback -> IO () # peekByteOff :: Ptr b -> Int -> IO SDL_NSTimerCallback # pokeByteOff :: Ptr b -> Int -> SDL_NSTimerCallback -> IO () # peek :: Ptr SDL_NSTimerCallback -> IO SDL_NSTimerCallback # poke :: Ptr SDL_NSTimerCallback -> SDL_NSTimerCallback -> IO () # | |||||
| Generic SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
Methods from :: SDL_NSTimerCallback -> Rep SDL_NSTimerCallback x # to :: Rep SDL_NSTimerCallback x -> SDL_NSTimerCallback # | |||||
| Show SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods showsPrec :: Int -> SDL_NSTimerCallback -> ShowS # show :: SDL_NSTimerCallback -> String # showList :: [SDL_NSTimerCallback] -> ShowS # | |||||
| Eq SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods (==) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # (/=) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # | |||||
| Ord SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods compare :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Ordering # (<) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # (<=) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # (>) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # (>=) :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> Bool # max :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> SDL_NSTimerCallback # min :: SDL_NSTimerCallback -> SDL_NSTimerCallback -> SDL_NSTimerCallback # | |||||
| HasFFIType SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
| |||||
| ReadRaw SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods readRaw :: Ptr SDL_NSTimerCallback -> IO SDL_NSTimerCallback # | |||||
| StaticSize SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods staticSizeOf :: Proxy SDL_NSTimerCallback -> Int # | |||||
| WriteRaw SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods writeRaw :: Ptr SDL_NSTimerCallback -> SDL_NSTimerCallback -> IO () # | |||||
| HasCField SDL_NSTimerCallback "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Associated Types
| |||||
| ty ~ FunPtr SDL_NSTimerCallback_Aux => HasField "unwrap" SDL_NSTimerCallback ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods hasField :: SDL_NSTimerCallback -> (ty -> SDL_NSTimerCallback, ty) # | |||||
| ty ~ FunPtr SDL_NSTimerCallback_Aux => HasField "unwrap" (Ptr SDL_NSTimerCallback) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer Methods getField :: Ptr SDL_NSTimerCallback -> Ptr ty # | |||||
| type Rep SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer type Rep SDL_NSTimerCallback = D1 ('MetaData "SDL_NSTimerCallback" "SDL3.Sys.Bindgen.Timer" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_NSTimerCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_NSTimerCallback_Aux)))) | |||||
| type FFIType SDL_NSTimerCallback Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||
| type CFieldType SDL_NSTimerCallback "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Timer | |||||