Trait Timer

Source
pub trait Timer: Send + Sync {
    // Required methods
    fn new_timeout(
        &self,
        task: Arc<dyn TimerTask>,
        delay: Duration,
    ) -> Arc<dyn Timeout>;
    fn stop(&self) -> HashSet<Arc<dyn Timeout>>;
}
Expand description

convert from netty Timer A trait representing a timer that can schedule and manage timed tasks.

Required Methods§

Source

fn new_timeout( &self, task: Arc<dyn TimerTask>, delay: Duration, ) -> Arc<dyn Timeout>

Schedules a new timeout task to be executed after the specified delay.

§Arguments
  • task - An Arc containing the task to be executed.
  • delay - The duration to wait before executing the task.
§Returns

An Arc containing the scheduled timeout.

Source

fn stop(&self) -> HashSet<Arc<dyn Timeout>>

Stops the timer and cancels all scheduled tasks.

§Returns

A HashSet containing all the cancelled timeouts.

Implementors§