Tokio
A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language. It is:
-
Fast: Tokio's zero-cost abstractions give you bare-metal performance.
-
Reliable: Tokio leverages Rust's ownership, type system, and concurrency model to reduce bugs and ensure thread safety.
-
Scalable: Tokio has a minimal footprint, and handles backpressure and cancellation naturally.
The API docs for the master branch are published here.
Overview
Tokio is an event-driven, non-blocking I/O platform for writing asynchronous applications with the Rust programming language. At a high level, it provides a few major components:
- A multithreaded, work-stealing based task scheduler.
- A reactor backed by the operating system's event queue (epoll, kqueue, IOCP, etc...).
- Asynchronous TCP and UDP sockets.
These components provide the runtime components necessary for building an asynchronous application.
Example
A basic TCP echo server with Tokio:
extern crate tokio;
use *;
use copy;
use TcpListener;
More examples can be found here.
Project layout
The tokio
crate, found at the root, is primarily intended for use by
application developers. Library authors should depend on the sub crates, which
have greater guarantees of stability.
The crates included as part of Tokio are:
-
tokio-executor
: Task execution related traits and utilities. -
tokio-io
: Asynchronous I/O related traits and utilities. -
tokio-reactor
: Event loop that drives I/O resources (like TCP and UDP sockets). -
tokio-threadpool
: Schedules the execution of futures across a pool of threads. -
tokio-tcp
: TCP bindings for use withtokio-io
andtokio-reactor
. -
tokio-udp
: UDP bindings for use withtokio-io
andtokio-reactor
.
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.