[−][src]Struct bbqueue::BBBuffer
A backing structure for a BBQueue. Can be used to create either a BBQueue or a split Producer/Consumer pair
Implementations
impl<'a, N> BBBuffer<N> where
N: ArrayLength<u8>,
[src]
N: ArrayLength<u8>,
pub fn try_split(&'a self) -> Result<(Producer<'a, N>, Consumer<'a, N>)>
[src]
Attempt to split the BBBuffer
into Consumer
and Producer
halves to gain access to the
buffer. If buffer has already been split, an error will be returned.
NOTE: When splitting, the underlying buffer will be explicitly initialized
to zero. This may take a measurable amount of time, depending on the size
of the buffer. This is necessary to prevent undefined behavior. If the buffer
is placed at static
scope within the .bss
region, the explicit initialization
will be elided (as it is already performed as part of memory initialization)
NOTE: If the thumbv6
feature is selected, this function takes a short critical section
while splitting.
use bbqueue::{BBBuffer, consts::*}; // Create and split a new buffer let buffer: BBBuffer<U6> = BBBuffer::new(); let (prod, cons) = buffer.try_split().unwrap(); // Not possible to split twice assert!(buffer.try_split().is_err());
pub fn try_split_framed(
&'a self
) -> Result<(FrameProducer<'a, N>, FrameConsumer<'a, N>)>
[src]
&'a self
) -> Result<(FrameProducer<'a, N>, FrameConsumer<'a, N>)>
Attempt to split the BBBuffer
into FrameConsumer
and FrameProducer
halves
to gain access to the buffer. If buffer has already been split, an error
will be returned.
NOTE: When splitting, the underlying buffer will be explicitly initialized
to zero. This may take a measurable amount of time, depending on the size
of the buffer. This is necessary to prevent undefined behavior. If the buffer
is placed at static
scope within the .bss
region, the explicit initialization
will be elided (as it is already performed as part of memory initialization)
NOTE: If the thumbv6
feature is selected, this function takes a short critical
section while splitting.
pub fn try_release(
&'a self,
prod: Producer<'a, N>,
cons: Consumer<'a, N>
) -> CoreResult<(), (Producer<'a, N>, Consumer<'a, N>)>
[src]
&'a self,
prod: Producer<'a, N>,
cons: Consumer<'a, N>
) -> CoreResult<(), (Producer<'a, N>, Consumer<'a, N>)>
Attempt to release the Producer and Consumer
This re-initializes the buffer so it may be split in a different mode at a later time. There must be no read or write grants active, or an error will be returned.
The Producer
and Consumer
must be from THIS BBBuffer
, or an error will
be returned.
use bbqueue::{BBBuffer, consts::*}; // Create and split a new buffer let buffer: BBBuffer<U6> = BBBuffer::new(); let (prod, cons) = buffer.try_split().unwrap(); // Not possible to split twice assert!(buffer.try_split().is_err()); // Release the producer and consumer assert!(buffer.try_release(prod, cons).is_ok()); // Split the buffer in framed mode let (fprod, fcons) = buffer.try_split_framed().unwrap();
pub fn try_release_framed(
&'a self,
prod: FrameProducer<'a, N>,
cons: FrameConsumer<'a, N>
) -> CoreResult<(), (FrameProducer<'a, N>, FrameConsumer<'a, N>)>
[src]
&'a self,
prod: FrameProducer<'a, N>,
cons: FrameConsumer<'a, N>
) -> CoreResult<(), (FrameProducer<'a, N>, FrameConsumer<'a, N>)>
Attempt to release the Producer and Consumer in Framed mode
This re-initializes the buffer so it may be split in a different mode at a later time. There must be no read or write grants active, or an error will be returned.
The FrameProducer
and FrameConsumer
must be from THIS BBBuffer
, or an error
will be returned.
impl<N> BBBuffer<N> where
N: ArrayLength<u8>,
[src]
N: ArrayLength<u8>,
pub fn capacity(&self) -> usize
[src]
Returns the size of the backing storage.
This is the maximum number of bytes that can be stored in this queue.
use bbqueue::{BBBuffer, consts::*}; // Create a new buffer of 6 elements let buffer: BBBuffer<U6> = BBBuffer::new(); assert_eq!(buffer.capacity(), 6);
impl<N> BBBuffer<N> where
N: ArrayLength<u8>,
[src]
N: ArrayLength<u8>,
pub fn new() -> Self
[src]
Create a new bbqueue
NOTE: For creating a bbqueue in static context, see ConstBBBuffer::new()
.
use bbqueue::{BBBuffer, consts::*}; // Create a new buffer of 6 elements let buffer: BBBuffer<U6> = BBBuffer::new();
Auto Trait Implementations
impl<N> !RefUnwindSafe for BBBuffer<N>
impl<N> Send for BBBuffer<N>
impl<N> Sync for BBBuffer<N>
impl<N> Unpin for BBBuffer<N> where
<N as ArrayLength<u8>>::ArrayType: Unpin,
<N as ArrayLength<u8>>::ArrayType: Unpin,
impl<N> UnwindSafe for BBBuffer<N> where
<N as ArrayLength<u8>>::ArrayType: UnwindSafe,
<N as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,