Struct tokio::runtime::Runtime [] [src]

pub struct Runtime { /* fields omitted */ }

Handle to the Tokio runtime.

The Tokio runtime includes a reactor as well as an executor for running tasks.

See module level documentation for more details.

Methods

impl Runtime
[src]

[src]

Create a new runtime instance with default configuration values.

See module level documentation for more details.

[src]

Return a reference to the reactor handle for this runtime instance.

[src]

Return a handle to the runtime's executor.

Important traits for &'a mut W
[src]

Spawn a future onto the Tokio runtime.

This spawns the given future onto the runtime's executor, usually a thread pool. The thread pool is then responsible for polling the future until it completes.

See module level documentation for more details.

Examples

use tokio::runtime::Runtime;

// Create the runtime
let mut rt = Runtime::new().unwrap();

// Spawn a future onto the runtime
rt.spawn(future::lazy(|| {
    println!("now running on a worker thread");
    Ok(())
}));

Panics

This function panics if the spawn fails. Failure occurs if the executor is currently at capacity and is unable to spawn a new future.

[src]

Signals the runtime to shutdown once it becomes idle.

Returns a future that completes once the shutdown operation has completed.

This function can be used to perform a graceful shutdown of the runtime.

The runtime enters an idle state once all of the following occur.

  • The thread pool has no tasks to execute, i.e., all tasks that were spawned have completed.
  • The reactor is not managing any I/O resources.

See module level documentation for more details.

[src]

Signals the runtime to shutdown immediately.

Returns a future that completes once the shutdown operation has completed.

This function will forcibly shutdown the runtime, causing any in-progress work to become canceled. The shutdown steps are:

  • Drain any scheduled work queues.
  • Drop any futures that have not yet completed.
  • Drop the reactor.

Once the reactor has dropped, any outstanding I/O resources bound to that reactor will no longer function. Calling any method on them will result in an error.

See module level documentation for more details.

Trait Implementations

impl Debug for Runtime
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Runtime

impl Sync for Runtime