Skip to main content

SenderHandle

Struct SenderHandle 

Source
pub struct SenderHandle<A: Actor> { /* private fields */ }
Expand description

A typed, Clone-able handle bound to one actor pid.

Use it from an external driver (Rust that owns the Scheduler and is not inside a slice) to SenderHandle::call the actor (blocking request/reply) or SenderHandle::cast it (fire-and-forget). Never call from inside a handler — it deadlocks the worker thread (module docs).

Implementations§

Source§

impl<A: Actor> SenderHandle<A>

Source

pub fn attach(scheduler: &Arc<Scheduler>, pid: u64) -> Self

Build a handle for an existing actor pid (e.g. a child from ActorContext::spawn_child).

Like a BEAM pid the handle is untyped on the wire: the caller asserts the process is an Actor of type A. An envelope the target cannot decode is ignored, so a type mismatch fails closed, never unsoundly.

Source

pub fn pid(&self) -> u64

The target actor’s pid.

Source

pub fn cast(&self, message: A::Cast) -> Result<(), ActorError>

Send a fire-and-forget cast to the actor and return immediately.

The send is performed by a transient native process so it routes through NativeContext::send / the LocalSendFacility with full sender-clock discipline — there is no side channel. A cast to a dead pid is silently dropped. Returns ActorError::Spawn only if the scheduler refused to create that transient sender.

Source

pub fn call(&self, request: A::Call) -> Result<A::Reply, ActorError>

Blocking request/reply: send request to the actor and return its reply, correlated by a unique ref so concurrent calls never cross replies.

MUST be called from an external driver, never from inside an actor handler — see the module-level deadlock note. Waits a default 5s for the reply; use SenderHandle::call_timeout to override.

Source

pub fn call_timeout( &self, request: A::Call, timeout: Duration, ) -> Result<A::Reply, ActorError>

SenderHandle::call with an explicit reply timeout.

Trait Implementations§

Source§

impl<A: Actor> Clone for SenderHandle<A>

Available on crate feature threads only.
Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for SenderHandle<A>

§

impl<A> !UnwindSafe for SenderHandle<A>

§

impl<A> Freeze for SenderHandle<A>

§

impl<A> Send for SenderHandle<A>

§

impl<A> Sync for SenderHandle<A>

§

impl<A> Unpin for SenderHandle<A>

§

impl<A> UnsafeUnpin for SenderHandle<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.