[−][src]Struct herbert::ActorContext
A handle to communication channels provided to an actor function.
Actor functions spawned through the router are passed an ActorContext
that provides the
Receviers
over which the actor receives messages and control messages from the router and
Senders
the actor can use to communicate back with the router.
This is typically only used by the router.
Fields
id: String
req: Receiver<Message>
ctl: Receiver<ActorCtl>
router_req: Sender<RouterRequest>
router_ctl: Sender<RouterCtl>
stat: Sender<ActorStatus>
Methods
impl ActorContext
[src]
pub fn new(
id: String,
req: Receiver<Message>,
ctl: Receiver<ActorCtl>,
router_req: Sender<RouterRequest>,
router_ctl: Sender<RouterCtl>,
stat: Sender<ActorStatus>
) -> Self
[src]
id: String,
req: Receiver<Message>,
ctl: Receiver<ActorCtl>,
router_req: Sender<RouterRequest>,
router_ctl: Sender<RouterCtl>,
stat: Sender<ActorStatus>
) -> Self
Construct an ActorContext
. This is typically used only by the router.
pub fn spawn(&self, id: &str, f: Box<ActorFn>) -> Result<()>
[src]
Spawn a new actor.
pub fn has(&self, id: &str) -> Result<bool>
[src]
Determine whether the router has a route to another actor, at the time of inspection.
pub fn get(&self, id: &str) -> Result<Sender<Message>>
[src]
Retrieve a copy of another actor's request channel Sender
.
pub fn send(&self, id: &str, msg: Message) -> Result<()>
[src]
Send a message to another actor.
pub fn stop(&self, id: &str) -> Result<()>
[src]
Stop another actor.
Warning: if attempting to stop another actor while in the process of being stopped, the router will be blocked awaiting a response. The router will not receive the stop request until after you have completed stopping and a deadlock will occur.
pub fn stop_async(&self, id: &str) -> Result<()>
[src]
Stop another actor without waiting for it to stop.
This should be used when stopping an actor from within an actor that is currently in the process of being stopped.
pub fn report_stopped(&self) -> Result<()>
[src]
Inform the router that we are stopping.
Auto Trait Implementations
impl RefUnwindSafe for ActorContext
impl Send for ActorContext
impl Sync for ActorContext
impl Unpin for ActorContext
impl UnwindSafe for ActorContext
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,