Struct Process

Source
pub struct Process<A: Actor<Context = Self>> { /* private fields */ }
Expand description

A special execution context. In this context the actor has a stable identity, whuch should not change. It can also receive messages from remote nodes.

Implementations§

Source§

impl<A> Process<A>
where A: ProcessDispatch + Actor<Context = Self>,

Source

pub fn start(a: A) -> Pid<A>

Start a new process

Source

pub fn start_with(f: impl FnOnce(&mut Self) -> A) -> Pid<A>

Start a new process, with the ability to manipiulate its context before actual startup

Source

pub fn pid(&self) -> Pid<A>

Get Pid of current process

Trait Implementations§

Source§

impl<A: Actor<Context = Self>> ActorContext for Process<A>

Source§

fn stop(&mut self)

Immediately stop processing incoming messages and switch to a stopping state. This only affects actors that are currently running. Future attempts to queue messages will fail.
Source§

fn terminate(&mut self)

Terminate actor execution unconditionally. This sets the actor into the stopped state. This causes future attempts to queue messages to fail.
Source§

fn state(&self) -> ActorState

Retrieve the current Actor execution state.
Source§

impl<A: Actor<Context = Self>> AsyncContext<A> for Process<A>

Source§

fn address(&self) -> Addr<A>

Returns the address of the context.
Source§

fn spawn<F>(&mut self, fut: F) -> SpawnHandle
where F: ActorFuture<Output = (), Actor = A> + 'static,

Spawns a future into the context. Read more
Source§

fn wait<F>(&mut self, fut: F)
where F: ActorFuture<Output = (), Actor = A> + 'static,

Spawns a future into the context, waiting for it to resolve. Read more
Source§

fn waiting(&self) -> bool

Checks if the context is paused (waiting for future completion or stopping).
Source§

fn cancel_future(&mut self, handle: SpawnHandle) -> bool

Cancels a spawned future. Read more
Source§

fn add_stream<S>(&mut self, fut: S) -> SpawnHandle
where S: Stream + 'static, A: StreamHandler<<S as Stream>::Item>,

Registers a stream with the context. Read more
Source§

fn add_message_stream<S>(&mut self, fut: S)
where S: Stream + 'static, <S as Stream>::Item: Message, A: Handler<<S as Stream>::Item>,

Registers a stream with the context, ignoring errors. Read more
Source§

fn notify<M>(&mut self, msg: M)
where A: Handler<M>, M: Message + 'static,

Sends the message msg to self. This bypasses the mailbox capacity, and will always queue the message. If the actor is in the stopped state, an error will be raised.
Source§

fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle
where A: Handler<M>, M: Message + 'static,

Sends the message msg to self after a specified period of time. Read more
Source§

fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle
where F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,

Executes a closure after a specified period of time. Read more
Source§

fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle
where F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,

Spawns a job to execute the given closure periodically, at a specified fixed interval.
Source§

impl<A: Actor<Context = Self>> AsyncContextParts<A> for Process<A>

Source§

fn parts(&mut self) -> &mut ContextParts<A>

Source§

impl<A, M> ToEnvelope<A, M> for Process<A>
where A: Handler<M> + Actor<Context = Self>, M: Send + 'static + Message, M::Result: Send,

Source§

fn pack(msg: M, tx: Option<Sender<<M as Message>::Result>>) -> Envelope<A>

Pack message into suitable envelope

Auto Trait Implementations§

§

impl<A> Freeze for Process<A>

§

impl<A> !RefUnwindSafe for Process<A>

§

impl<A> !Send for Process<A>

§

impl<A> !Sync for Process<A>

§

impl<A> Unpin for Process<A>

§

impl<A> !UnwindSafe for Process<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V