Struct sdl2::TimerSubsystem
source · pub struct TimerSubsystem { /* private fields */ }
Implementations§
source§impl TimerSubsystem
impl TimerSubsystem
sourcepub fn add_timer<'b, 'c>(
&'b self,
delay: u32,
callback: TimerCallback<'c>,
) -> Timer<'b, 'c>
pub fn add_timer<'b, 'c>( &'b self, delay: u32, callback: TimerCallback<'c>, ) -> Timer<'b, 'c>
Constructs a new timer using the boxed closure callback
.
The timer is started immediately, it will be cancelled either:
- when the timer is dropped
- or when the callback returns a non-positive continuation interval
The callback is run in a thread that is created and managed internally by SDL2 from C. The callback must not panic!
sourcepub fn ticks(&self) -> u32
pub fn ticks(&self) -> u32
Gets the number of milliseconds elapsed since the timer subsystem was initialized.
It’s recommended that you use another library for timekeeping, such as time
.
This function is not recommended in upstream SDL2 as of 2.0.18 and internally calls the 64-bit variant and masks the result.
sourcepub fn ticks64(&self) -> u64
pub fn ticks64(&self) -> u64
Gets the number of milliseconds elapsed since the timer subsystem was initialized.
It’s recommended that you use another library for timekeeping, such as time
.
sourcepub fn delay(&self, ms: u32)
pub fn delay(&self, ms: u32)
Sleeps the current thread for the specified amount of milliseconds.
It’s recommended that you use std::thread::sleep()
instead.
pub fn performance_counter(&self) -> u64
pub fn performance_frequency(&self) -> u64
Trait Implementations§
source§impl Clone for TimerSubsystem
impl Clone for TimerSubsystem
source§fn clone(&self) -> TimerSubsystem
fn clone(&self) -> TimerSubsystem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more