Trait cbsk_timer::timer::Timer

source ·
pub trait Timer: 'static {
    // Required methods
    fn name(&self) -> &str;
    fn run(&self);

    // Provided methods
    fn run_before(&self) -> bool { ... }
    fn ended(&self) -> bool { ... }
    fn interval(&self) -> Option<Duration> { ... }
    fn start(self)
       where Self: Sized { ... }
}
Expand description

timer tasks

Required Methods§

source

fn name(&self) -> &str

timer name

source

fn run(&self)

timer run logic

Provided Methods§

source

fn run_before(&self) -> bool

ren before, default return true
please execute the non blocking logic that ends immediately
do nothing when return false
execute Self::run in the thread pool when return true

source

fn ended(&self) -> bool

the timer is ended
default is false

source

fn interval(&self) -> Option<Duration>

task loop interval
if return None, will run continuously

source

fn start(self)
where Self: Sized,

start timer

Implementors§

source§

impl Timer for SimpleTimer

support timer