[][src]Struct bbqueue::BBQueue

pub struct BBQueue { /* fields omitted */ }

A single producer, single consumer, thread safe queue

Methods

impl BBQueue
[src]

pub unsafe fn unpinned_new(buf: &'static mut [u8]) -> Self
[src]

Create a new BBQueue with a given backing buffer. After giving this buffer to `BBQueue::new(), the backing buffer must not be used, or undefined behavior could occur!

Additionally, when using BBQueue::split(), the BBQueue struct must never be moved, otherwise Producer and Consumer could corrupt memory

Consider using the bbq!() macro to safely create a statically allocated instance, or enable the "std" feature, and instead use the BBQueue::new_boxed() constructor.

pub fn grant(&mut self, sz: usize) -> Result<GrantW>
[src]

Request a writable, contiguous section of memory of exactly sz bytes. If the buffer size requested is not available, an error will be returned.

pub fn grant_max(&mut self, sz: usize) -> Result<GrantW>
[src]

Request a writable, contiguous section of memory of up to sz bytes. If a buffer of size sz is not available, but some space (0 < available < sz) is available, then a grant will be given for the remaining size. If no space is available for writing, an error will be returned

pub fn commit(&mut self, used: usize, grant: GrantW)
[src]

Finalizes a writable grant given by grant() or grant_max(). This makes the data available to be read via read().

If used is larger than the given grant, this function will panic.

pub fn read(&mut self) -> Result<GrantR>
[src]

Obtains a contiguous slice of committed bytes. This slice may not contain ALL available bytes, if the writer has wrapped around. The remaining bytes will be available after all readable bytes are released

pub fn release(&self, used: usize, grant: GrantR)
[src]

Release a sequence of bytes from the buffer, allowing the space to be used by later writes

If used is larger than the given grant, this function will panic.

impl BBQueue
[src]

pub fn split(&self) -> (Producer, Consumer)
[src]

This method takes a BBQueue, and returns a set of SPSC handles that may be given to separate threads. May only be called once per BBQueue object, or this function will panic

impl BBQueue
[src]

pub fn new_boxed(capacity: usize) -> Box<Self>
[src]

Creates a Boxed BBQueue

NOTE: This function essentially "leaks" the backing buffer (e.g. BBQueue::new_boxed(1024) will leak 1024 bytes). This may be changed in the future.

pub fn split_box(queue: Box<Self>) -> (Producer, Consumer)
[src]

Splits a boxed BBQueue into a producer and consumer

Trait Implementations

impl Debug for BBQueue
[src]

Auto Trait Implementations

impl !Send for BBQueue

impl !Sync for BBQueue

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]