[][src]Trait calloop::EventDispatcher

pub trait EventDispatcher<Data> {
    fn ready(&mut self, ready: Option<&Event>, data: &mut Data);
}

An event dispatcher

It is the junction between user callbacks and and an event source, receiving readinesses events, converting them into appropriate events and calling their inner user callback.

Depending on the kind of your source, the dispatching will be done differently.

  • OS-based source will receive an mio::Event signalling the readiness of their resource. Note that there may be spurious wakeups and the resource may end up not being actually ready. When receiving a readiness event you should process the resource until it is no longer ready, or you might never receive any future notification (as the source would never "become" ready again).
  • Purely userspace sources are polled every time the event loop wakes up (be it from mio or a waker). As calloop cannot identify which of them is ready, all of them are called with a None value for readiness. Your source is then responsible for checking if it is actually ready, and if yes call its underlying callback appropriately.

Required methods

fn ready(&mut self, ready: Option<&Event>, data: &mut Data)

The source has a readiness event

Loading content...

Implementors

Loading content...