Struct veilid_tools::TickTask
source · pub struct TickTask<E: Send + 'static> { /* private fields */ }
Expand description
Runs a single-future background processing task, attempting to run it once every ‘tick period’ microseconds. If the prior tick is still running, it will allow it to finish, and do another tick when the timer comes around again. One should attempt to make tasks short-lived things that run in less than the tick period if you want things to happen with regular periodicity.
Implementations§
source§impl<E: Send + 'static> TickTask<E>
impl<E: Send + 'static> TickTask<E>
pub fn new_us(tick_period_us: u64) -> Self
pub fn new_ms(tick_period_ms: u32) -> Self
pub fn new(tick_period_sec: u32) -> Self
pub fn set_routine( &self, routine: impl Fn(StopToken, u64, u64) -> SendPinBoxFuture<Result<(), E>> + Send + Sync + 'static )
pub fn is_running(&self) -> bool
pub fn last_timestamp_us(&self) -> Option<u64>
pub async fn stop(&self) -> Result<(), E>
pub async fn tick(&self) -> Result<(), E>
pub async fn try_tick_now(&self) -> Result<bool, E>
Auto Trait Implementations§
impl<E> !Freeze for TickTask<E>
impl<E> !RefUnwindSafe for TickTask<E>
impl<E> Send for TickTask<E>
impl<E> Sync for TickTask<E>
impl<E> Unpin for TickTask<E>
impl<E> !UnwindSafe for TickTask<E>
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more