A more appealing model is actually just automatically inferring what needs to be scheduled based on what actions are done during poll. For example if during a poll you check a oneshot channel, then the current task is registered for being woken up if it's not ready. Similarly this will apply to I/O where if I/O is attempted but we see EAGAIN then we'll schedule the task to get notified when it's ready. This may also have performance benefits in some niche situations because you don't need to recompute where you are in the state machine both during poll and during schedule. Instead, it now happens all at once.
futures-mio
Bindings to the mio crate implementing the futures-io and futures
abstractions.
Usage
First, add this to your Cargo.toml:
[dependencies]
futures-mio = { git = "https://github.com/alexcrichton/futures-rs" }
Next, add this to your crate:
extern crate futures_mio;
Examples
There are a few small examples showing off how to use this library:
What is futures-mio?
This crate is a connection futures, a zero-cost implementation of futures in
Rust, and mio, a crate for zero-cost asynchronous I/O, and futures-io,
abstractions for I/O on top of the futures crate. The types and structures
implemented in futures-mio implement Future and Stream traits as
appropriate. For example connecting a TCP stream returns a Future resolving
to a TCP stream, and a TCP listener implements a stream of TCP streams
(accepted connections).
This crate also provides facilities such as:
- TCP streams
- TCP listeners
- UDP sockets
- Timeouts
- Data owned and local to the event loop
- An
Executorimplementation for a futures'Task
The intention of futures-mio is to provide a concrete implementation for
crates built on top of futures-io. For example you can easily turn a TCP
stream into a TLS/SSL stream with the futures-tls crate or use the
combinators to compose working with data on sockets.
Check out the documentation for more information, and more coming here soon!
License
futures-mio is primarily distributed under the terms of both the MIT license
and the Apache License (Version 2.0), with portions covered by various BSD-like
licenses.
See LICENSE-APACHE, and LICENSE-MIT for details.