Struct actix::prelude::Context [−][src]
Expand description
An actor execution context.
Implementations
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);
}
}
let addr = MyActor.start();
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.
fn spawn<F>(&mut self, fut: F) -> SpawnHandle where
F: ActorFuture<Output = (), Actor = A> + 'static,
fn spawn<F>(&mut self, fut: F) -> SpawnHandle where
F: ActorFuture<Output = (), Actor = A> + 'static,
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>,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
S: Stream + 'static,
A: StreamHandler<S::Item>,
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,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
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,
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut A::Context) + 'static,
Spawns a job to execute the given closure periodically, at a specified fixed interval. Read more