pub struct Channel {
pub subscribers: Vec<TaskId>,
/* private fields */
}Expand description
spc_006-04: many-to-one / one-to-many fan-in. Unlike Mailbox, a published message is
never removed from the shared buffer — each subscriber reads independently via its own
cursor into that buffer (the doc’s “共享 buffer + per-consumer 已读游标” design; the cursors
field is not shown in spc_006 §3’s abbreviated struct sketch but is mechanically required to
realize that description — without it a second consumer draining after a first would see
nothing).
Fields§
§subscribers: Vec<TaskId>Implementations§
Source§impl Channel
impl Channel
pub fn new(subscribers: Vec<TaskId>) -> Self
pub fn publish(&mut self, msg: MailboxMessage)
pub fn publish_at( &mut self, msg: MailboxMessage, now: LogicalTime, ) -> IpcEnqueueOutcome
Sourcepub fn drain_for(&mut self, consumer: TaskId) -> Vec<MailboxMessage>
pub fn drain_for(&mut self, consumer: TaskId) -> Vec<MailboxMessage>
Every message published since consumer’s last drain_for, oldest first; advances that
consumer’s cursor to the current end of the buffer. Independent of every other consumer’s
cursor — draining does not consume the buffer.
pub fn drain_for_at( &mut self, consumer: TaskId, now: LogicalTime, ) -> Vec<MailboxMessage>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Channel
impl<'de> Deserialize<'de> for Channel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Channel
impl StructuralPartialEq for Channel
Auto Trait Implementations§
impl Freeze for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnsafeUnpin for Channel
impl UnwindSafe for Channel
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