Struct actix::Context [−][src]
Expand description
An actor execution context.
Implementations
Create a context without spawning it.
The context can be spawned into an actor using its run
method.
struct Actor1 { actor2_addr: Addr<Actor2>, } struct Actor2 { actor1_addr: Addr<Actor1>, } let ctx1 = Context::<Actor1>::new(); let ctx2 = Context::<Actor2>::new(); let actor1 = Actor1 { actor2_addr: ctx2.address() }; let actor2 = Actor2 { actor1_addr: ctx1.address() }; ctx1.run(actor1); ctx2.run(actor2);
Returns a handle to the running future.
This is the handle returned by the AsyncContext::spawn()
method.
Sets the mailbox capacity.
The default mailbox capacity is 16 messages. #Examples
struct MyActor; impl Actor for MyActor { type Context = Context<Self>; fn started(&mut self, ctx: &mut Self::Context) { ctx.set_mailbox_capacity(1); System::current().stop(); } } let addr = sys.block_on(async { MyActor.start() }); sys.run();
Trait Implementations
Immediately stop processing incoming messages and switch to a
stopping
state. This only affects actors that are currently
running
. Future attempts to queue messages will fail. Read more
Terminate actor execution unconditionally. This sets the actor
into the stopped
state. This causes future attempts to queue
messages to fail. Read more
Retrieve the current Actor execution state.
Spawns a future into the context. Read more
Spawns a future into the context, waiting for it to resolve. Read more
Checks if the context is paused (waiting for future completion or stopping).
Cancels a spawned future. Read more
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
S: Stream + 'static,
A: StreamHandler<S::Item>,
[src]
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
S: Stream + 'static,
A: StreamHandler<S::Item>,
[src]Registers a stream with the context. Read more
Registers a stream with the context, ignoring errors. Read more
Sends the message msg
to self. This bypasses the mailbox capacity, and
will always queue the message. If the actor is in the stopped
state, an
error will be raised. Read more
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
[src]
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
[src]Sends the message msg
to self after a specified period of time. Read more
Executes a closure after a specified period of time. Read more
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut A::Context) + 'static,
[src]
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut A::Context) + 'static,
[src]Spawns a job to execute the given closure periodically, at a specified fixed interval. Read more
Auto Trait Implementations
impl<A> !RefUnwindSafe for Context<A>
impl<A> !UnwindSafe for Context<A>