Struct mio::Poll [] [src]

pub struct Poll { /* fields omitted */ }

Polls for readiness events on all registered values.

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 Ready 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 as well as the `Events` we'll store into
let poll = Poll::new().unwrap();
let mut events = Events::with_capacity(1024);

// 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), Ready::all(), PollOpt::edge()).unwrap();

// Wait for the socket to become ready
poll.poll(&mut events, None).unwrap();

Methods

impl Poll
[src]

Return a new Poll handle using a default configuration.

Register an Evented handle with the Poll instance.

Re-register an Evented handle with the Poll instance.

Deregister an Evented handle with the Poll instance.

Block the current thread and wait until any Evented values registered with the Poll instance are ready or the given timeout has elapsed.

Trait Implementations

impl Debug for Poll
[src]

Formats the value using the given formatter.