pub struct IpcQuota {
pub channels: AtomicU32,
pub queue_slots: AtomicU64,
pub buffered_bytes: AtomicU64,
}Expand description
Per-process IPC resource counters.
All fields are atomic so they can be updated without holding a global
lock. They are always accessed from the owning process’s context (the
syscall handler), so Relaxed ordering is sufficient for the common
case; AcqRel is used for the reserve/release pair to ensure that a
failed reservation is never silently lost.
Fields§
§channels: AtomicU32Number of live channel capabilities (handles) held by this process.
queue_slots: AtomicU64Sum of capacity across all channels created by this process.
buffered_bytes: AtomicU64queue_slots * size_of::<IpcMessage>() : total bytes that could be
buffered across all channels.
Implementations§
Source§impl IpcQuota
impl IpcQuota
Sourcepub fn try_reserve(&self, capacity: usize) -> Result<(), QuotaExceeded>
pub fn try_reserve(&self, capacity: usize) -> Result<(), QuotaExceeded>
Try to reserve resources for a new channel.
Returns Ok(()) if the reservation fits within the process quota,
Err(QuotaExceeded) otherwise. On failure nothing is modified.
Sourcepub fn release(&self, capacity: usize)
pub fn release(&self, capacity: usize)
Release resources previously reserved by [try_reserve].
Must be called exactly once for every successful try_reserve.
Passing a capacity that was never reserved will underflow the
counters : the caller must ensure correctness.
Sourcepub fn snapshot(&self) -> QuotaSnapshot
pub fn snapshot(&self) -> QuotaSnapshot
Returns a snapshot of the current counters.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for IpcQuota
impl RefUnwindSafe for IpcQuota
impl Send for IpcQuota
impl Sync for IpcQuota
impl Unpin for IpcQuota
impl UnsafeUnpin for IpcQuota
impl UnwindSafe for IpcQuota
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