Function actix_web::actix::run [−]
pub fn run<F, R>(f: F) where
F: FnOnce() -> R,
R: Future<Item = (), Error = ()> + 'static,
Start the System and execute supplied future.
This function does the following:
- Creates and starts actix System with default configuration.
- Spawn the given future onto the current arbiter.
- Block the current thread until the system shuts down.
run
functions returns when System::current().stop()
method get 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 actix system is already running.