pub struct Task<T, E = Error> {
pub f: fn(Event<'_, T>) -> Result<(), E>,
pub hz: f32,
pub max_time_micros: u16,
pub is_high_priority: bool,
pub last_run: u16,
}
Expand description
A task to run at specific frequency
Fields§
§f: fn(Event<'_, T>) -> Result<(), E>
The function to run.
hz: f32
The desired frequency (in hz) to run the task.
max_time_micros: u16
The max time for this task (in microseconds).
is_high_priority: bool
Determines if this task should be run every time the scheduler loops.
last_run: u16
The last tick this task was ran.
Implementations§
Source§impl<T, E> Task<T, E>
impl<T, E> Task<T, E>
Sourcepub fn new(f: fn(Event<'_, T>) -> Result<(), E>) -> Self
pub fn new(f: fn(Event<'_, T>) -> Result<(), E>) -> Self
Create a new task from the function to run.
Sourcepub fn high_priority(f: fn(Event<'_, T>) -> Result<(), E>) -> Self
pub fn high_priority(f: fn(Event<'_, T>) -> Result<(), E>) -> Self
Create a new high priority task from the function to run.
Sourcepub fn with_max_time(self, micros: u16) -> Self
pub fn with_max_time(self, micros: u16) -> Self
Builder method to set max_time_micros
and return self
Sourcepub fn with_high_priority(self, is_high_priority: bool) -> Self
pub fn with_high_priority(self, is_high_priority: bool) -> Self
Builder method to set is_high_priority
and return self
Sourcepub fn ticks(&self, loop_rate_hz: i16) -> i16
pub fn ticks(&self, loop_rate_hz: i16) -> i16
Calculate the desired ticks between each run of the task
Auto Trait Implementations§
impl<T, E> Freeze for Task<T, E>
impl<T, E> RefUnwindSafe for Task<T, E>
impl<T, E> Send for Task<T, E>
impl<T, E> Sync for Task<T, E>
impl<T, E> Unpin for Task<T, E>
impl<T, E> UnwindSafe for Task<T, 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