pub struct System { /* fields omitted */ }
System is an actor which manages runtime.
Before starting any actix's actors, System
actor has to be created and
started with System::run()
call. This method creates new Arbiter
in
current thread and starts System
actor.
extern crate actix;
use actix::prelude::*;
use std::time::Duration;
struct Timer {
dur: Duration,
}
impl Actor for Timer {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Context<Self>) {
ctx.run_later(self.dur, |act, ctx| {
System::current().stop();
});
}
}
fn main() {
let code = System::run(|| {
Timer {
dur: Duration::new(0, 1),
}.start();
});
std::process::exit(code);
}
Build a new system with a customized tokio runtime.
This allows to customize the runtime. See struct level docs on
Builder
for more information.
Create new system.
This method panics if it can not create tokio runtime
Get current running system.
Execute function with system reference.
Stop the system with a particular exit code.
Get current system registry.
This function will start tokio runtime and will finish once the
System::stop()
message get called.
Function f
get called within tokio runtime context.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static