pub struct TaskScheduler { /* private fields */ }Expand description
Manages scheduled and periodic tasks
Implementations§
Source§impl TaskScheduler
impl TaskScheduler
pub fn new() -> Self
Sourcepub fn set_next_handle(&self, handle_id: u64)
pub fn set_next_handle(&self, handle_id: u64)
Set the next handle ID to use (for synchronization with pre-generated handles)
Sourcepub fn schedule_every_internal(
&mut self,
task: Box<dyn PoolTask>,
interval: Duration,
priority: Priority,
) -> TaskHandle
pub fn schedule_every_internal( &mut self, task: Box<dyn PoolTask>, interval: Duration, priority: Priority, ) -> TaskHandle
Schedule a task to run at fixed intervals (internal implementation)
Sourcepub fn cancel(&mut self, handle: TaskHandle)
pub fn cancel(&mut self, handle: TaskHandle)
Cancel a scheduled task
Sourcepub fn get_ready_tasks(&mut self) -> Vec<Box<dyn PoolTask>>
pub fn get_ready_tasks(&mut self) -> Vec<Box<dyn PoolTask>>
Get all tasks that are ready to run
Sourcepub fn next_run_time(&self) -> Option<Instant>
pub fn next_run_time(&self) -> Option<Instant>
Get the next scheduled run time
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Get number of scheduled tasks
Auto Trait Implementations§
impl !Freeze for TaskScheduler
impl !RefUnwindSafe for TaskScheduler
impl Send for TaskScheduler
impl Sync for TaskScheduler
impl Unpin for TaskScheduler
impl !UnwindSafe for TaskScheduler
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