pub struct AsyncCustomScheduler<INSTANT, SLEEPER> { /* private fields */ }
Implementations§
Source§impl<INSTANT, SLEEPER> AsyncCustomScheduler<INSTANT, SLEEPER>where
INSTANT: Instant,
SLEEPER: AsyncSleeper,
impl<INSTANT, SLEEPER> AsyncCustomScheduler<INSTANT, SLEEPER>where
INSTANT: Instant,
SLEEPER: AsyncSleeper,
Sourcepub fn new(target_hz: f32) -> Selfwhere
SLEEPER: Default,
pub fn new(target_hz: f32) -> Selfwhere
SLEEPER: Default,
Constructs a new AsyncCustomScheduler struct that can schedule tasks at the given frequency target_hz
.
Sourcepub fn with_sleeper(target_hz: f32, sleeper: SLEEPER) -> Self
pub fn with_sleeper(target_hz: f32, sleeper: SLEEPER) -> Self
Constructs a new AsyncCustomScheduler struct that can schedule tasks at the given frequency target_hz
.
Sourcepub fn set_hz(&mut self, new_target_hz: f32)
pub fn set_hz(&mut self, new_target_hz: f32)
Allows you to change the frequency at which the scheduler tries to run tasks.
Sourcepub async fn loop_forever(&mut self, task: impl FnMut()) -> !
pub async fn loop_forever(&mut self, task: impl FnMut()) -> !
Lets you run a task at a fixed interval, forever.
Sourcepub async fn loop_while_true(&mut self, task: impl FnMut() -> bool)
pub async fn loop_while_true(&mut self, task: impl FnMut() -> bool)
Lets you run a task at a fixed interval. Will break when the function returns false.
Sourcepub async fn loop_until_err<T>(
&mut self,
task: impl FnMut() -> Result<T, Box<dyn Error>>,
) -> Box<dyn Error>
pub async fn loop_until_err<T>( &mut self, task: impl FnMut() -> Result<T, Box<dyn Error>>, ) -> Box<dyn Error>
Lets you run a task at a fixed interval. Will break when the function returns a result of Err variant.
Sourcepub async fn sleep_until_next_frame(&mut self)
pub async fn sleep_until_next_frame(&mut self)
Can be called manually to sleep until the next scheduled frame.
Valuable for when you’d like to avoid having to pass values into a closure, or would like more control over loop flow.
Trait Implementations§
Source§impl<INSTANT: Clone, SLEEPER: Clone> Clone for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT: Clone, SLEEPER: Clone> Clone for AsyncCustomScheduler<INSTANT, SLEEPER>
Source§fn clone(&self) -> AsyncCustomScheduler<INSTANT, SLEEPER>
fn clone(&self) -> AsyncCustomScheduler<INSTANT, SLEEPER>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<INSTANT, SLEEPER> Default for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT, SLEEPER> Default for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT: Copy, SLEEPER: Copy> Copy for AsyncCustomScheduler<INSTANT, SLEEPER>
Auto Trait Implementations§
impl<INSTANT, SLEEPER> Freeze for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT, SLEEPER> RefUnwindSafe for AsyncCustomScheduler<INSTANT, SLEEPER>where
INSTANT: RefUnwindSafe,
SLEEPER: RefUnwindSafe,
impl<INSTANT, SLEEPER> Send for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT, SLEEPER> Sync for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT, SLEEPER> Unpin for AsyncCustomScheduler<INSTANT, SLEEPER>
impl<INSTANT, SLEEPER> UnwindSafe for AsyncCustomScheduler<INSTANT, SLEEPER>where
INSTANT: UnwindSafe,
SLEEPER: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more