[−][src]Struct thespis_impl::Mailbox
The mailbox implementation.
Implementations
impl<A> Mailbox<A> where
A: Actor,
[src]
A: Actor,
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]
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.
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]
A: Send,
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]
self,
actor: A,
exec: &impl SpawnHandle<Option<Self>>
) -> ThesRes<JoinHandle<Option<Self>>> where
A: Send,
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]
self,
actor: A,
exec: &impl LocalSpawnHandle<Option<Self>>
) -> ThesRes<JoinHandle<Option<Self>>>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,