sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

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

Documentation

sDL_MS_PER_SECOND :: CInt Source #

C declaration
macro SDL_MS_PER_SECOND, defined at SDL3/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 at SDL3/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 at SDL3/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 at SDL3/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 at SDL3/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 at SDL3/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 at SDL3/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 at SDL3/SDL_timer.h 185:9

Since: 3.2.0

newtype SDL_TimerID Source #

Definition of the timer ID type.

C declaration
SDL_TimerID, defined at SDL3/SDL_timer.h 306:16

Since: 3.2.0

Constructors

SDL_TimerID 

Fields

Instances

Instances details
Bits SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

FiniteBits SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Bounded SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Enum SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Storable SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Generic SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type Rep SDL_TimerID 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

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

Defined in SDL3.Sys.Bindgen.Timer

Num SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Read SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Integral SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Real SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Show SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Eq SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Ord SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Prim SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasFFIType SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type FFIType SDL_TimerID 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ReadRaw SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

StaticSize SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

WriteRaw SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Methods

writeRaw :: Ptr SDL_TimerID -> SDL_TimerID -> IO () #

Bitfield SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasCField SDL_TimerID "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type CFieldType SDL_TimerID "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type CFieldType SDL_TimerID "unwrap" = Uint32

Methods

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

ty ~ Uint32 => HasField "unwrap" SDL_TimerID ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Methods

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

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

Defined in SDL3.Sys.Bindgen.Timer

Methods

getField :: Ptr SDL_TimerID -> Ptr ty #

type Rep SDL_TimerID Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

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

Defined in SDL3.Sys.Bindgen.Timer

type CFieldType SDL_TimerID "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type CFieldType SDL_TimerID "unwrap" = Uint32

newtype SDL_TimerCallback_Aux Source #

Auxiliary type used by SDL_TimerCallback

C declaration
SDL_TimerCallback, defined at SDL3/SDL_timer.h 332:26

Constructors

SDL_TimerCallback_Aux 

Fields

Instances

Instances details
Generic SDL_TimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type Rep SDL_TimerCallback_Aux 
Instance details

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))))
FromFunPtr SDL_TimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ToFunPtr SDL_TimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasCField SDL_TimerCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type CFieldType SDL_TimerCallback_Aux "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Methods

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

ty ~ (Ptr Void -> SDL_TimerID -> Uint32 -> IO Uint32) => HasField "unwrap" SDL_TimerCallback_Aux ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ty ~ (Ptr Void -> SDL_TimerID -> Uint32 -> IO Uint32) => HasField "unwrap" (Ptr SDL_TimerCallback_Aux) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type Rep SDL_TimerCallback_Aux Source # 
Instance details

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 # 
Instance details

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 at SDL3/SDL_timer.h 332:26

Since: 3.2.0

Instances

Instances details
Storable SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Generic SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type Rep SDL_TimerCallback 
Instance details

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))))
Show SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Eq SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Ord SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasFFIType SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ReadRaw SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

StaticSize SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

WriteRaw SDL_TimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasCField SDL_TimerCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type CFieldType SDL_TimerCallback "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Methods

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

ty ~ FunPtr SDL_TimerCallback_Aux => HasField "unwrap" SDL_TimerCallback ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ty ~ FunPtr SDL_TimerCallback_Aux => HasField "unwrap" (Ptr SDL_TimerCallback) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type Rep SDL_TimerCallback Source # 
Instance details

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 # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type CFieldType SDL_TimerCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

newtype SDL_NSTimerCallback_Aux Source #

Auxiliary type used by SDL_NSTimerCallback

C declaration
SDL_NSTimerCallback, defined at SDL3/SDL_timer.h 394:26

Instances

Instances details
Generic SDL_NSTimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type Rep SDL_NSTimerCallback_Aux 
Instance details

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))))
FromFunPtr SDL_NSTimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ToFunPtr SDL_NSTimerCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasCField SDL_NSTimerCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type CFieldType SDL_NSTimerCallback_Aux "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ty ~ (Ptr Void -> SDL_TimerID -> Uint64 -> IO Uint64) => HasField "unwrap" SDL_NSTimerCallback_Aux ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ty ~ (Ptr Void -> SDL_TimerID -> Uint64 -> IO Uint64) => HasField "unwrap" (Ptr SDL_NSTimerCallback_Aux) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type Rep SDL_NSTimerCallback_Aux Source # 
Instance details

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 # 
Instance details

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 at SDL3/SDL_timer.h 394:26

Since: 3.2.0

Instances

Instances details
Storable SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Generic SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type Rep SDL_NSTimerCallback 
Instance details

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))))
Show SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Eq SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Ord SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasFFIType SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ReadRaw SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

StaticSize SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

WriteRaw SDL_NSTimerCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

HasCField SDL_NSTimerCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Associated Types

type CFieldType SDL_NSTimerCallback "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

Methods

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

ty ~ FunPtr SDL_NSTimerCallback_Aux => HasField "unwrap" SDL_NSTimerCallback ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

ty ~ FunPtr SDL_NSTimerCallback_Aux => HasField "unwrap" (Ptr SDL_NSTimerCallback) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type Rep SDL_NSTimerCallback Source # 
Instance details

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 # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer

type CFieldType SDL_NSTimerCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Timer