pub(crate) struct Pipe {
pub(crate) head: AtomicUsize,
pub(crate) tail: AtomicUsize,
pub(crate) reader: AtomicWaker,
pub(crate) writer: AtomicWaker,
pub(crate) closed: AtomicBool,
pub(crate) buffer: *mut u8,
pub(crate) cap: usize,
}Expand description
The inner ring buffer.
Head and tail indices are in the range 0..2*cap, even though they really map onto the
0..cap range. The distance between head and tail indices is never more than cap.
The reason why indices are not in the range 0..cap is because we need to distinguish between
the pipe being empty and being full. If head and tail were in 0..cap, then head == tail
could mean the pipe is either empty or full, but we don’t know which!
Fields§
§head: AtomicUsizeThe head index, moved by the reader, in the range 0..2*cap.
tail: AtomicUsizeThe tail index, moved by the writer, in the range 0..2*cap.
reader: AtomicWakerA waker representing the blocked reader.
writer: AtomicWakerA waker representing the blocked writer.
closed: AtomicBoolSet to true if the reader or writer was dropped.
buffer: *mut u8The byte buffer.
cap: usizeThe buffer capacity.
Implementations§
Trait Implementations§
Auto Trait Implementations§
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