MIO for Rust

The Event Loop

The core of mio is the EventLoop API.

The lifecycle of an event loop involves:

  • Creating a new event loop (EventLoop::new or EventLoop::configured)
  • Registering interest in events (EventLoop::register)
  • Running the event loop with a Handler, waiting for events (EventLoop::run or EventLoop::run_once)
  • Sending a message to the event loop (EventLoop::channel().send())
  • Shutting down the event loop (EventLoop::shutdown)

When the event loop is shut down, it will finish sending any pending messages to the registered handler, and return Ok(handler) from the original call to EventLoop::run().