Struct mio::Poll [] [src]

pub struct Poll {
    // some fields omitted
}

The Poll type acts as an interface allowing a program to wait on a set of IO handles until one or more become "ready" to be operated on. An IO handle is considered ready to operate on when the given operation can complete without blocking.

To use Poll, an IO handle must first be registered with the Poll instance using the register() handle. An EventSet representing the program's interest in the socket is specified as well as an arbitrary Token which is used to identify the IO handle in the future.

Edge-triggered and level-triggered

An IO handle registration may request edge-triggered notifications or level-triggered notifications. This is done by specifying the PollOpt argument to register() and reregister().

Portability

Cross platform portability is provided for Mio's TCP & UDP implementations.

Examples

use mio::*;
use mio::tcp::*;

// Construct a new `Poll` handle
let mut poll = Poll::new().unwrap();

// Connect the stream
let stream = TcpStream::connect(&"173.194.33.80:80".parse().unwrap()).unwrap();

// Register the stream with `Poll`
poll.register(&stream, Token(0), EventSet::all(), PollOpt::edge()).unwrap();

// Wait for the socket to become ready
poll.poll(None).unwrap();

Methods

impl Poll

fn new() -> Result<Poll>

fn register<E: ?Sized>(&mut self, io: &E, token: Token, interest: EventSet, opts: PollOpt) -> Result<()> where E: Evented

fn reregister<E: ?Sized>(&mut self, io: &E, token: Token, interest: EventSet, opts: PollOpt) -> Result<()> where E: Evented

fn deregister<E: ?Sized>(&mut self, io: &E) -> Result<()> where E: Evented

fn poll(&mut self, timeout: Option<Duration>) -> Result<usize>

fn events(&self) -> Events

Trait Implementations

impl Debug for Poll

fn fmt(&self, fmt: &mut Formatter) -> Result