Expand description
Actor execution context
Implementations
sourceimpl<A> Context<A>where
A: Actor<Context = Context<A>>,
impl<A> Context<A>where
A: Actor<Context = Context<A>>,
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, Context<A>>
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
sourceimpl<A> ActorContext for Context<A>where
A: Actor<Context = Context<A>>,
impl<A> ActorContext for Context<A>where
A: Actor<Context = Context<A>>,
sourceimpl<A> AsyncContext<A> for Context<A>where
A: Actor<Context = Context<A>>,
impl<A> AsyncContext<A> for Context<A>where
A: Actor<Context = Context<A>>,
sourcefn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: 'static + ActorFuture<Item = (), Error = (), Actor = A>,
fn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: 'static + ActorFuture<Item = (), Error = (), Actor = A>,
Spawn async future into context. Returns handle of the item,
could be used for cancelling execution. Read more
sourcefn wait<F>(&mut self, fut: F)where
F: 'static + ActorFuture<Item = (), Error = (), Actor = A>,
fn wait<F>(&mut self, fut: F)where
F: 'static + ActorFuture<Item = (), Error = (), Actor = A>,
Spawn future into the context. Stop processing any of incoming events
until this future resolves. Read more
sourcefn waiting(&self) -> bool
fn waiting(&self) -> bool
Check if context is paused (waiting for future completion or stopping)
sourcefn 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.sourcefn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
This method register stream to an actor context and
allows to handle
Stream
in similar way as normal actor messages. Read moresourcefn add_message_stream<S>(&mut self, fut: S)where
S: 'static + Stream<Error = ()>,
<S as Stream>::Item: Message,
A: Handler<<S as Stream>::Item>,
fn add_message_stream<S>(&mut self, fut: S)where
S: 'static + Stream<Error = ()>,
<S as Stream>::Item: Message,
A: Handler<<S as Stream>::Item>,
This method is similar to
add_stream
but it skips stream errors. Read moresourcefn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: 'static + Message,
fn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: 'static + Message,
Send message
msg
to self.sourcefn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: 'static + Message,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: 'static + Message,
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 moresourcefn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnOnce(&mut A, &mut <A as Actor>::Context),
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnOnce(&mut A, &mut <A as Actor>::Context),
Execute closure after specified period of time within same Actor and
Context. Execution get cancelled if context’s stop method get
called. Read more
sourcefn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
Spawns a job to execute the given closure periodically, at a specified
fixed interval Read more
sourceimpl<A> AsyncContextParts<A> for Context<A>where
A: Actor<Context = Context<A>>,
impl<A> AsyncContextParts<A> for Context<A>where
A: Actor<Context = Context<A>>,
fn parts(&mut self) -> &mut ContextParts<A>
Auto Trait Implementations
impl<A> !RefUnwindSafe for Context<A>
impl<A> !Send for Context<A>
impl<A> !Sync for Context<A>
impl<A> Unpin for Context<A>
impl<A> !UnwindSafe for Context<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more