Struct rotor::Scope [] [src]

pub struct Scope<'a, C: Sized + 'a> {
    // some fields omitted
}

The structure passed to every action handler

Scope is used for the following purposes:

  1. Register/deregister sockets in the event loop
  2. Register timeouts
  3. Create a special Notifier object to wakeup sibling state machines
  4. Access to global state of the loop (Context)

All methods here operate on enclosed state machine, which means the state machine that was called with this scope. Or in other words the state machine that actually performs an action.

The only way to notify another state machine is to create a notifier() (the Notifier is only able to wakeup this state machine still), transfer it to another state machine (for example putting it into the context) and call Notifier::wakeup().

The structure derefs to the context (C) for convenience

Methods

impl<'a, C: Sized + 'a> Scope<'a, C>

fn register(&mut self, io: &Evented, interest: EventSet, opt: PollOpt) -> Result<()>

fn reregister(&mut self, io: &Evented, interest: EventSet, opt: PollOpt) -> Result<()>

fn deregister(&mut self, io: &Evented) -> Result<()>

fn timeout_ms(&mut self, delay: u64) -> Result<Timeout, TimerError>

Add timeout

This method is deprecated use return value of your state machine's action to set a timeout

fn clear_timeout(&mut self, token: Timeout) -> bool

Clear timeout

This method is deprecated (with timeout_ms) use return value of your state machine's action to change a timeout

fn notifier(&mut self) -> Notifier

Create a Notifier that may be used to wakeup enclosed state machine

fn shutdown_loop(&mut self)

Shutdown the event loop

fn now(&self) -> Time

Time of the current loop iteration

This is a time that needs to be used for timeouts. It's cheap to use

fn estimate_timespec(&self, time: Time) -> Timespec

Returns the Timespec that corresponds to the Time in this loop

Note: this is an estimate, because we use monotonic time under the hood, but Timespec is a subject for adjustments of the system clock.

I.e. it is fine to use this time to present it to the user, but it's wrong to rely on it in code.

Trait Implementations

impl<'a, C: Sized + 'a> GenericScope for Scope<'a, C>

fn register(&mut self, io: &Evented, interest: EventSet, opt: PollOpt) -> Result<()>

fn reregister(&mut self, io: &Evented, interest: EventSet, opt: PollOpt) -> Result<()>

fn deregister(&mut self, io: &Evented) -> Result<()>

fn timeout_ms(&mut self, delay: u64) -> Result<Timeout, TimerError>

fn clear_timeout(&mut self, token: Timeout) -> bool

fn notifier(&mut self) -> Notifier

fn now(&self) -> Time

fn estimate_timespec(&self, time: Time) -> Timespec

impl<'a, C> Deref for Scope<'a, C>

type Target = C

fn deref(&self) -> &C

impl<'a, C> DerefMut for Scope<'a, C>

fn deref_mut(&mut self) -> &mut C