[][src]Struct thespis_impl::Mailbox

pub struct Mailbox<A> where
    A: Actor
{ /* fields omitted */ }

The mailbox implementation.

Implementations

impl<A> Mailbox<A> where
    A: Actor
[src]

pub fn new(name: Option<Arc<str>>, rx: ChanReceiver<A>) -> Self[src]

Create a new inbox.

pub fn span(&self) -> Span[src]

Obtain a tracing::Span identifying the actor with it's id and it's name if it has one.

pub async fn start(self, actor: A) -> Option<Self> where
    A: Send
[src]

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.

pub async fn start_local(self, actor: A) -> Option<Self>[src]

Run the mailbox with a non-Send Actor. 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.

pub fn spawn(self, actor: A, exec: &impl Spawn) -> ThesRes<()> where
    A: Send
[src]

Spawn the mailbox. Use this if you don't want to supervise the actor and don't want a JoinHandle.

pub fn start_handle(
    self,
    actor: A,
    exec: &impl SpawnHandle<Option<Self>>
) -> ThesRes<JoinHandle<Option<Self>>> where
    A: Send
[src]

Spawn the mailbox. You get a joinhandle you can await to detect when the mailbox terminates and which will return you the mailbox if the actor panicked during message processing. You can use this to supervise the actor.

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.

If you drop the handle, the mailbox will be dropped and the actor will be stopped and Actor::stopped will not be called.

pub fn spawn_local(self, actor: A, exec: &impl LocalSpawn) -> ThesRes<()>[src]

Spawn the mailbox on the current thread. Use this if you don't want to supervise the actor and don't want a JoinHandle.

pub fn spawn_handle_local(
    self,
    actor: A,
    exec: &impl LocalSpawnHandle<Option<Self>>
) -> ThesRes<JoinHandle<Option<Self>>>
[src]

Spawn the mailbox on the current thread. You get a joinhandle you can await to detect when the mailbox terminates and which will return you the mailbox if the actor panicked during message processing. You can use this to supervise the actor.

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.

If you drop the handle, the mailbox will be dropped and the actor will be stopped and Actor::stopped will not be called.

Trait Implementations

impl<A: Actor> Debug for Mailbox<A>[src]

impl<A: Actor> Display for Mailbox<A>[src]

impl<A: Actor> Identify for Mailbox<A>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithSubscriber for T[src]