Crate tokio_executor[][src]

Task execution related traits and utilities.

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.



Abstraction over blocking and unblocking the current thread.



Executes futures on the default executor for the current execution context.


Represents an executor context.


An error returned by enter if an execution scope has already been entered.


Errors returned by Executor::spawn.



A value that executes futures.



Marks the current thread as being within the dynamic extent of an executor.


Submits a future for execution on the default executor -- usually a threadpool.


Set the default executor for the duration of the closure