tokio/tokio-executor
Carl Lerche 1c5d131245
Allow customizing the threadpool's parker (#264)
* Allow customizing the threadpool's parker

This patch allows the user of threadpool to customize how the worker
threads park themselves. This allows custom parking logic to be
injected. For example, this allows embedding a timer on each worker
thread.

* Call `park` instance every so often.

Since the `park` is now customizable, it might have logic that must be
called every so often. For example, a timer might have timeouts that it
must expire.

Currently, if a worker is very busy, it won't call into the `park`
instance. This patch changes this so that after every 32 task
invocations, `park` is called with a duration of zero.
2018-03-29 13:47:08 -07:00
..
2018-03-23 10:34:42 -07:00

tokio-executor

Task execution related traits and utilities.

Documentation

Overview

In the Tokio execution model, futures are lazy. When a future is created, no work is performed. In order for the work defined by the future to happen, the future must be submitted to an executor. A future that is submitted to an executor is called a "task".

The executor is responsible for ensuring that [Future::poll] is called whenever the task is [notified]. Notification happens when the internal state of a task transitions from "not ready" to ready. For example, a socket might have received data and a call to read will now be able to succeed.

This crate provides traits and utilities that are necessary for building an executor, including:

  • The Executor trait describes the API for spawning a future onto an executor.

  • enter marks that the the current thread is entering an execution context. This prevents a second executor from accidentally starting from within the context of one that is already running.

  • DefaultExecutor spawns tasks onto the default executor for the current context.

  • Park abstracts over blocking and unblocking the current thread.

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.