pub struct Port {
pub id: PortId,
pub owner: TaskId,
queue: ArrayQueue<IpcMessage>,
destroyed: AtomicBool,
send_waitq: WaitQueue,
recv_waitq: WaitQueue,
}Expand description
An IPC port: a bounded message queue with blocking semantics.
Fields§
§id: PortIdUnique port identifier.
owner: TaskIdTaskId of the port’s creator/owner.
queue: ArrayQueue<IpcMessage>The message queue (bounded to PORT_QUEUE_CAPACITY).
destroyed: AtomicBoolSet to true when the port is destroyed; blocked tasks wake with error.
send_waitq: WaitQueueTasks blocked because the queue is full (waiting to send).
recv_waitq: WaitQueueTasks blocked because the queue is empty (waiting to receive).
Implementations§
Source§impl Port
impl Port
Sourcepub fn send(&self, msg: IpcMessage) -> Result<(), IpcError>
pub fn send(&self, msg: IpcMessage) -> Result<(), IpcError>
Send a message to this port.
If the queue is full, the calling task blocks until space is available.
Returns Err(IpcError::PortDestroyed) if the port is destroyed while
the sender is blocked.
Sourcepub fn recv(&self) -> Result<IpcMessage, IpcError>
pub fn recv(&self) -> Result<IpcMessage, IpcError>
Receive a message from this port.
If the queue is empty, the calling task blocks until a message arrives.
Returns Err(IpcError::PortDestroyed) if the port is destroyed while
the receiver is blocked.
Sourcepub fn try_send(&self, msg: IpcMessage) -> Result<(), IpcError>
pub fn try_send(&self, msg: IpcMessage) -> Result<(), IpcError>
Try to send a message to this port without blocking.
Returns Ok(()) if the message was queued,
or Err(WouldBlock) if the queue is full.
Sourcepub fn try_recv(&self) -> Result<Option<IpcMessage>, IpcError>
pub fn try_recv(&self) -> Result<Option<IpcMessage>, IpcError>
Try to receive a message from this port without blocking.
Returns Ok(Some(msg)) if a message was available, Ok(None) if empty,
or Err(IpcError::PortDestroyed) if the port is destroyed.
Sourcepub fn has_messages(&self) -> bool
pub fn has_messages(&self) -> bool
Returns whether messages is available.
Sourcepub fn is_destroyed(&self) -> bool
pub fn is_destroyed(&self) -> bool
Returns whether destroyed.
Auto Trait Implementations§
impl !Freeze for Port
impl !RefUnwindSafe for Port
impl Send for Port
impl Sync for Port
impl Unpin for Port
impl UnsafeUnpin for Port
impl UnwindSafe for Port
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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