Expand description
Actor execution context
Implementations§
source§impl<A> Context<A>where
A: Actor<Context = Self>,
impl<A> Context<A>where
A: Actor<Context = Self>,
pub fn with_receiver(rx: AddressReceiver<A>) -> Context<A>
pub fn run(self, act: A) -> Addr<A>
pub fn into_future(self, act: A) -> ContextFut<A, Self>
sourcepub fn handle(&self) -> SpawnHandle
pub fn handle(&self) -> SpawnHandle
Handle of the running future
SpawnHandle is the handle returned by AsyncContext::spawn()
method.
sourcepub fn set_mailbox_capacity(&mut self, cap: usize)
pub fn set_mailbox_capacity(&mut self, cap: usize)
Set mailbox capacity
By default mailbox capacity is 16 messages.
Trait Implementations§
source§impl<A> ActorContext for Context<A>where
A: Actor<Context = Self>,
impl<A> ActorContext for Context<A>where
A: Actor<Context = Self>,
source§impl<A> AsyncContext<A> for Context<A>where
A: Actor<Context = Self>,
impl<A> AsyncContext<A> for Context<A>where
A: Actor<Context = Self>,
source§fn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
fn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn async future into context. Returns handle of the item,
could be used for cancelling execution. Read more
source§fn wait<F>(&mut self, fut: F)where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
fn wait<F>(&mut self, fut: F)where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn future into the context. Stop processing any of incoming events
until this future resolves. Read more
source§fn waiting(&self) -> bool
fn waiting(&self) -> bool
Check if context is paused (waiting for future completion or stopping)
source§fn cancel_future(&mut self, handle: SpawnHandle) -> bool
fn cancel_future(&mut self, handle: SpawnHandle) -> bool
Cancel future. handle is a value returned by
spawn
method.source§fn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: Stream + 'static,
A: StreamHandler<S::Item, S::Error>,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: Stream + 'static,
A: StreamHandler<S::Item, S::Error>,
This method register stream to an actor context and
allows to handle
Stream
in similar way as normal actor messages. Read moresource§fn add_message_stream<S>(&mut self, fut: S)where
S: Stream<Error = ()> + 'static,
S::Item: Message,
A: Handler<S::Item>,
fn add_message_stream<S>(&mut self, fut: S)where
S: Stream<Error = ()> + 'static,
S::Item: Message,
A: Handler<S::Item>,
This method is similar to
add_stream
but it skips stream errors. Read moresource§fn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: Message + 'static,
fn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: Message + 'static,
Send message
msg
to self.source§fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: Message + 'static,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: Message + 'static,
Send message
msg
to self after specified period of time. Returns
spawn handle which could be used for cancellation. Notification get
cancelled if context’s stop method get called. Read moresource§fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: FnOnce(&mut A, &mut A::Context) + 'static,
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: FnOnce(&mut A, &mut A::Context) + 'static,
Execute closure after specified period of time within same Actor and
Context. Execution get cancelled if context’s stop method get
called. Read more
source§fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: FnMut(&mut A, &mut A::Context) + 'static,
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: FnMut(&mut A, &mut A::Context) + 'static,
Spawns a job to execute the given closure periodically, at a specified
fixed interval Read more