[][src]Struct stakker_mio::MioPoll

pub struct MioPoll { /* fields omitted */ }

Ref-counting wrapper around a mio Poll instance

After creation, pass cloned copies of this to all interested parties. A MioPoll reference is also available from the associated Stakker instance using cx.anymap_get::<MioPoll>().

Implementations

impl MioPoll[src]

pub fn new(
    stakker: &mut Stakker,
    poll: Poll,
    events: Events,
    waker_pri: u32
) -> Result<Self>
[src]

Create a new MioPoll instance wrapping the given mio Poll instance and mio Events queue (which the caller should size according to their requirements). The waker priority should also be provided, in the range 0..=10. Sets up the Stakker instance to use MioPoll as the poll-waker, and puts a MioPoll clone into the Stakker anymap.

pub fn add<S: Source>(
    &self,
    source: S,
    ready: Interest,
    pri: u32,
    fwd: Fwd<Ready>
) -> Result<MioSource<S>>
[src]

Register a mio Source object with the poll instance. Returns a MioSource which takes care of cleaning up the token and handler when it is dropped.

This uses edge-triggering: whenever one of the Interest flags included in ready changes state, the given Fwd instance will be invoked with the new Ready value. The contract with the handler is that there may be spurious calls to it, so it must be ready for that.

pri gives a priority level: 0..=10. If handlers are registered at different priority levels, then higher priority events get handled before lower priority events. Under constant very heavy load, lower priority events might be delayed indefinitely.

pub fn poll(&self, max_delay: Duration) -> Result<bool>[src]

Poll for new events and queue all the events of the highest available priority level. Events of lower priority levels are queued internally to be used on a future call to this method.

So the expected pattern is that highest-priority handlers get run, and when all the resulting processing has completed in Stakker, then the main loop polls again, and if more high-priority events have occurred, then those too will get processed. Lower-priority handlers will only get a chance to run when nothing higher-priority needs handling.

On success returns Ok(true) if an event was processed, or Ok(false) if there were no new events.

pub fn set_wake_fwd(&mut self, fwd: Fwd<Ready>)[src]

Set the handler for "wake" events. There can only be one handler for "wake" events, so setting it here drops the previous handler. Don't call this unless you wish to override the default wake handling which calls stakker::Stakker::poll_wake.

pub fn waker(&mut self) -> Arc<Waker>[src]

Get a cloned reference to the waker for this MioPoll instance. This can be passed to other threads, which can call wake() on it to cause the wake handler to be run in the main polling thread.

Trait Implementations

impl Clone for MioPoll[src]

Auto Trait Implementations

impl !RefUnwindSafe for MioPoll

impl !Send for MioPoll

impl !Sync for MioPoll

impl Unpin for MioPoll

impl !UnwindSafe for MioPoll

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.