Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn is_started(&mut self) -> bool;
    fn is_alive(&mut self) -> bool;
    fn start(&mut self);
    fn stop(&mut self);
    fn post(&mut self, func: RawFunc);
}
Expand description

Handler trait defines the interface which could receive FnMut and run them on its own thread.

§Remarks

This is highly inspired by Android Handler concepts.

Required Methods§

Source

fn is_started(&mut self) -> bool

Did this Handler start? Return true when it did started (no matter it has stopped or not)

Source

fn is_alive(&mut self) -> bool

Is this Handler alive? Return true when it has started and not stopped yet.

Source

fn start(&mut self)

Start Handler.

Source

fn stop(&mut self)

Stop Cor. This will make self.is_alive() returns false, and all FnMut posted by self.post() will not be executed. (Because it has stopped :P, that’s reasonable)

Source

fn post(&mut self, func: RawFunc)

Post a job which will run on this Handler.

§Arguments
  • func - The posted job. ``

Implementors§