pub struct MessageChannel<F: IntegrateFloat> { /* private fields */ }Expand description
Message channel for inter-node communication
Implementations§
Source§impl<F: IntegrateFloat> MessageChannel<F>
impl<F: IntegrateFloat> MessageChannel<F>
Sourcepub fn generate_message_id(&self) -> u64
pub fn generate_message_id(&self) -> u64
Generate a new message ID
Sourcepub fn send(
&self,
target: NodeId,
message: DistributedMessage<F>,
) -> DistributedResult<u64>
pub fn send( &self, target: NodeId, message: DistributedMessage<F>, ) -> DistributedResult<u64>
Send a message to a node
Sourcepub fn receive(
&self,
timeout: Duration,
) -> Option<(NodeId, DistributedMessage<F>)>
pub fn receive( &self, timeout: Duration, ) -> Option<(NodeId, DistributedMessage<F>)>
Receive a message (blocking with timeout)
Sourcepub fn try_receive(&self) -> Option<(NodeId, DistributedMessage<F>)>
pub fn try_receive(&self) -> Option<(NodeId, DistributedMessage<F>)>
Receive a message (non-blocking)
Sourcepub fn deliver(
&self,
source: NodeId,
message: DistributedMessage<F>,
) -> DistributedResult<()>
pub fn deliver( &self, source: NodeId, message: DistributedMessage<F>, ) -> DistributedResult<()>
Deliver a message to the inbox (called by network layer)
Sourcepub fn process_ack(
&self,
message_id: u64,
status: AckStatus,
) -> DistributedResult<()>
pub fn process_ack( &self, message_id: u64, status: AckStatus, ) -> DistributedResult<()>
Process acknowledgment
Sourcepub fn check_timeouts(&self) -> Vec<(u64, NodeId)>
pub fn check_timeouts(&self) -> Vec<(u64, NodeId)>
Check for timed-out messages
Sourcepub fn outbox_size(&self) -> usize
pub fn outbox_size(&self) -> usize
Get outbox size
Sourcepub fn inbox_size(&self) -> usize
pub fn inbox_size(&self) -> usize
Get inbox size
Sourcepub fn drain_outbox(&self) -> Vec<(NodeId, DistributedMessage<F>)>
pub fn drain_outbox(&self) -> Vec<(NodeId, DistributedMessage<F>)>
Drain outbox for sending
Auto Trait Implementations§
impl<F> !Freeze for MessageChannel<F>
impl<F> RefUnwindSafe for MessageChannel<F>
impl<F> Send for MessageChannel<F>where
F: Send,
impl<F> Sync for MessageChannel<F>where
F: Send,
impl<F> Unpin for MessageChannel<F>where
F: Unpin,
impl<F> UnsafeUnpin for MessageChannel<F>
impl<F> UnwindSafe for MessageChannel<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more