pub trait ActorExt:
Actor
+ ActorBehaviorAsync
+ ActorHooksAsync {
// Provided method
fn start(self) -> Addr<Self> { ... }
}
Provided Methods§
Sourcefn start(self) -> Addr<Self>
fn start(self) -> Addr<Self>
Starts the actor.
Examples found in repository?
More examples
examples/accumulator.rs (line 53)
50fn run() {
51 let actor = Accumulator { sum: 0 };
52
53 let addr = Accum(actor.start());
54
55 let _feeder = task::spawn(async move {
56 for _i in 0..1_000_000_usize {
57 while addr.overloaded() {
58 sleep(Duration::from_millis(1)).await;
59 // println!("Overload");
60 }
61 addr.add(1);
62 }
63 });
64}
examples/accumulator_proc_macro.rs (line 29)
28async fn run() {
29 let accumulator = Accumulator { sum: 0 }.start();
30
31 let feeder = task::spawn(async move {
32 for _i in 0..1_000_000_usize {
33 while accumulator.overloaded() {
34 sleep(Duration::from_millis(1)).await;
35 // println!("Overload");
36 }
37 accumulator.add(1);
38 }
39 });
40
41 feeder.await.unwrap();
42}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.