Struct thespis_impl::Mailbox
source · [−]pub struct Mailbox<A> where
A: Actor, { /* private fields */ }
Expand description
The mailbox implementation.
Implementations
sourceimpl<A> Mailbox<A> where
A: Actor,
impl<A> Mailbox<A> where
A: Actor,
sourcepub fn new(name: Option<&str>, rx: ChanReceiver<A>) -> Self
pub fn new(name: Option<&str>, rx: ChanReceiver<A>) -> Self
Create a new inbox.
sourcepub fn addr(&self, tx: ChanSender<A>) -> Addr<A>
pub fn addr(&self, tx: ChanSender<A>) -> Addr<A>
Create an Addr
to send messages to this mailbox.
sourcepub async fn start(self, actor: A) -> MailboxEnd<A> where
A: Send,
pub async fn start(self, actor: A) -> MailboxEnd<A> where
A: Send,
Run the mailbox. Returns a future that processes incoming messages. If the actor panics during message processing, this will return the mailbox to you so you can supervise actors by re-initiating your actor and then calling this method on the mailbox again. All addresses will remain valid in this scenario.
This means that we use AssertUnwindSafe
and
catch_unwind
when calling your actor
and the thread will not unwind. This means that your actor should implement
std::panic::UnwindSafe
. This might become an enforced trait bound for Actor
in
the future.
Warning: if you drop the future returned by this function in order to stop an actor,
Actor::stopped
will not be called.
sourcepub async fn start_local(self, actor: A) -> MailboxEnd<A>
pub async fn start_local(self, actor: A) -> MailboxEnd<A>
Exactly as Mailbox::start
, but works for !Send
actors.
Trait Implementations
Auto Trait Implementations
impl<A> !RefUnwindSafe for Mailbox<A>
impl<A> Send for Mailbox<A>
impl<A> !Sync for Mailbox<A>
impl<A> Unpin for Mailbox<A>
impl<A> !UnwindSafe for Mailbox<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more