Function actix::run[][src]

pub fn run<R>(f: R) -> Result<()> where
    R: Future<Output = ()> + '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 actix_rt::time::sleep;

fn main() {
  actix::run(async move {
      sleep(Duration::from_millis(100)).await;
      actix::System::current().stop();
  });
}

Panics

This function panics if the actix system is already running.