[][src]Function actix::run

pub fn run<F, R>(f: F) -> Result<()> where
    F: FnOnce() -> R,
    R: Future<Item = (), Error = ()> + 'static, 

Starts the system and executes the supplied future.

This function does the following:

  • Creates and starts the actix system with default configuration.
  • Spawns the given future onto the current arbiter.
  • Blocks the current thread until the system shuts down.

The run function returns when the System::current().stop() method gets called.

Examples

use std::time::{Duration, Instant};
use tokio_timer::Delay;

fn main() {
  actix::run(
      || Delay::new(Instant::now() + Duration::from_millis(100))
           .map(|_| actix::System::current().stop())
           .map_err(|_| ())
  );
}

Panics

This function panics if the actix system is already running.