Files
tokio/tokio-reactor
Eliza Weisman 22b7bd2f51 [0.1.x] add set_default to 0.1 executor, timer, and reactor (#1725)
This commit adds `set_default` drop guard style APIs for setting the
default reactor, executor, and timer. These are similar to the APIs used
in `tokio` 0.2

In addition to having potentially better ergonomics than the
`with_default` closure APIs, the drop-guard based APIs will be helpful
in rewriting the `tokio-compat` crate to wrap the existing tokio 0.2
runtime, rather than constructing its own runtime.

Because the runtime does not expose an `around_worker` API, it cannot
currently be used with the 0.1 `with_default` method of setting the
reactor, timer, and executor. This means that tokio-compat must
duplicate a lot of existing code from `tokio` to construct the runtime,
which is unfortunate (and has the potential to introduce errors). On the
other hand, we can use the drop guard APIs with `before_start` and
`after_stop`, by storing the drop guards in a thread-local. This will
allow `tokio-compat` to wrap the 0.2 runtime, reducing code duplication.
Also, this will allow the blocking pool to be used on the compat
runtime, which is currently impossible (as the blocking APIs are private
to `tokio`).

Signed-off-by: Eliza Weisman <[email protected]>
2019-11-06 15:53:33 -08:00
..
2019-01-06 23:25:55 -08:00

tokio-reactor

Event loop that drives Tokio I/O resources.

Documentation

Overview

The reactor is the engine that drives asynchronous I/O resources (like TCP and UDP sockets). It is backed by mio and acts as a bridge between mio and futures.

The crate provides:

  • Reactor is the main type of this crate. It performs the event loop logic.

  • Handle provides a reference to a reactor instance.

  • Registration and PollEvented allow third parties to implement I/O resources that are driven by the reactor.

Application authors will not use this crate directly. Instead, they will use the tokio crate. Library authors should only depend on tokio-reactor if they are building a custom I/O resource.

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.