[][src]Function tokio::run

pub fn run<F>(future: F) where
    F: Future<Item = (), Error = ()> + Send + 'static, 

Start the Tokio runtime using the supplied future to bootstrap execution.

This function is used to bootstrap the execution of a Tokio application. It does the following:

  • Start the Tokio runtime using a default configuration.
  • Spawn the given future onto the thread pool.
  • Block the current thread until the runtime shuts down.

Note that the function will not return immediately once future has completed. Instead it waits for the entire runtime to become idle.

See the module level documentation for more details.


use tokio::net::TcpListener;

let listener = TcpListener::bind(&addr).unwrap();

let server = listener.incoming()
    .map_err(|e| println!("error = {:?}", e))
    .for_each(|socket| {



This function panics if called from the context of an executor.