pub struct Channel<M: Send> { /* private fields */ }
Expand description
Channel for sending messages to an actor
A Channel
may be used to send messages of type M
to an actor
from any thread. It is an unbounded queue.
Messages are delivered directly to an actor method via a Fwd
instance. Cleanup of the channel is handled via a
ChannelGuard
which should be kept in the same actor. When
this is dropped, the channel is closed, and senders are informed
via the Channel::send
and Channel::is_closed
methods. So
this handles cleanup automatically when the actor fails or
terminates for any reason.
Implementations§
source§impl<M: Send> Channel<M>
impl<M: Send> Channel<M>
sourcepub fn new(core: &mut Core, fwd: Fwd<M>) -> (Self, ChannelGuard)
pub fn new(core: &mut Core, fwd: Fwd<M>) -> (Self, ChannelGuard)
Create a new channel that directs messages to an actor using
the given Fwd
instance. Returns the channel and a
channel-guard. The Channel
may be cloned as many times as
necessary and sent to other threads. The ChannelGuard
should be kept in the actor that receives the messages.