[][src]Struct stakker::ActorOwn

pub struct ActorOwn<A: 'static> { /* fields omitted */ }

An owning ref-counting reference to an actor

This not only keeps a reference to the actor, but it will also automatically terminate the actor when the last owning reference is dropped. This dereferences to a normal Actor reference, so when .clone() is called on it, a normal non-owning reference results. To get another owning reference, use .owned().

Implementations

impl<A: 'static> ActorOwn<A>[src]

pub fn new(
    core: &mut Core,
    notify: Ret<StopCause>,
    parent_id: LogID
) -> ActorOwn<A>
[src]

Create a new uninitialised actor of the given type. This is in the Prep state. The reference can be cloned and passed around and used to create Fwd or Ret instances. However all calls to be actor will be delayed until the actor moves into the Ready state.

notify is the StopCause return, which is called when the actor terminates. parent_id is the logging-ID of the parent actor if known, or else 0.

See macros actor! and actor_new! for help with creating and initialising actors.

pub fn kill(&self, s: &mut Stakker, err: Box<dyn Error>)[src]

Kill actor, moving to Zombie state and dropping the contained actor Self value. The actor can never return from the Zombie state. The provided error is used to generate an StopCause::Killed instance, which is passed to the StopCause handler set up when the actor was created.

pub fn kill_str(&self, s: &mut Stakker, err: &'static str)[src]

Kill actor, moving to Zombie state and dropping the contained actor Self value. The actor can never return from the Zombie state. The provided error string is used to generate an StopCause::Killed instance, which is passed to the StopCause handler set up when the actor was created.

pub fn kill_string(&self, s: &mut Stakker, err: impl Into<String>)[src]

Kill actor, moving to Zombie state and dropping the contained actor Self value. The actor can never return from the Zombie state. The provided error string is used to generate an StopCause::Killed instance, which is passed to the StopCause handler set up when the actor was created.

pub fn anon(self) -> ActorOwnAnon[src]

Convert into an anonymous owning reference. See ActorOwnAnon.

Methods from Deref<Target = Actor<A>>

pub fn owned(&self) -> ActorOwn<A>[src]

Create an additional owning reference to this actor. When the last owning reference is dropped, the actor is terminated, even when there are other references active.

pub fn is_zombie(&self) -> bool[src]

Check whether the actor is a zombie. Note that this call is less useful than it appears, since the actor may become a zombie between the time you make this call and whatever asynchronous operation follows. It is better to make a call with a ret_to! callback which will send back a None if the actor has died or if the actor drops the Ret for any other reason.

pub fn apply_prep(
    &self,
    s: &mut Stakker,
    f: impl FnOnce(&mut Cx<'_, A>) -> Option<A>
)
[src]

Apply a closure to the actor if it is in the Prep state, otherwise do nothing. This is used to implement deferred prep calls.

pub fn apply(
    &self,
    s: &mut Stakker,
    f: impl FnOnce(&mut A, &mut Cx<'_, A>) + 'static
)
[src]

Apply a closure to the actor when it reaches the Ready state. If the actor is already in the Ready state, the closure is executed immediately. If the actor is in the Prep state, then it queues the operation instead of executing it. This is used to implement deferred ready calls.

pub fn query<R>(
    &self,
    s: &mut Stakker,
    f: impl FnOnce(&mut A, &mut Cx<'_, A>) -> R
) -> Option<R>
[src]

Query an actor from outside the runtime. This is a synchronous call intended for use when interfacing to external code. Executes the closure on the actor immediately if the actor has a Self value (i.e. is in the Ready state), and returns the result. Otherwise returns None.

pub fn id(&self) -> LogID[src]

Get the logging-ID of this actor. If the logger feature isn't enabled, returns 0.

pub fn defer(&self, f: impl FnOnce(&mut Stakker) + 'static)[src]

This may be used to submit items to the Deferrer main queue from a drop handler, without needing a Core reference.

pub fn access_deferrer(&self) -> &Deferrer[src]

Used in macros to get a Deferrer reference

pub fn access_actor(&self) -> &Self[src]

Used in macros to get an Actor reference

pub fn access_log_id(&self) -> LogID[src]

Used in macros to get the actor's logging-ID. If the logger feature isn't enabled, returns 0.

Trait Implementations

impl<A: 'static> Deref for ActorOwn<A>[src]

type Target = Actor<A>

The resulting type after dereferencing.

impl<A: 'static> DerefMut for ActorOwn<A>[src]

impl<A: 'static> Drop for ActorOwn<A>[src]

Auto Trait Implementations

impl<A> !RefUnwindSafe for ActorOwn<A>

impl<A> !Send for ActorOwn<A>

impl<A> !Sync for ActorOwn<A>

impl<A> Unpin for ActorOwn<A>

impl<A> !UnwindSafe for ActorOwn<A>

Blanket Implementations

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

impl<T> Any for T where
    T: Any
[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, U> Into<U> for T where
    U: From<T>, 
[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.