[][src]Struct triple_buffer::Output

pub struct Output<T: Send> { /* fields omitted */ }

Consumer interface to the triple buffer

The consumer of data can use this struct to access the latest published update from the producer whenever he likes. Readout is nonblocking: a collision between the producer and consumer will result in cache contention, but deadlocks and scheduling-induced slowdowns cannot happen.

Implementations

impl<T: Send> Output<T>[src]

pub fn read(&mut self) -> &T[src]

Access the latest value from the triple buffer

pub fn updated(&self) -> bool[src]

Tell whether a buffer update is incoming from the producer

This method is only intended for diagnostics purposes. Please do not let it inform your decision of reading a value or not, as that would effectively be building a very poor spinlock-based double buffer implementation. If what you truly need is a double buffer, build yourself a proper blocking one instead of wasting CPU time.

pub fn output_buffer(&mut self) -> &mut T[src]

Access the output buffer directly

This advanced interface allows you to modify the contents of the output buffer, so that you can avoid copying the output value when this is an expensive process. One possible application, for example, is to post-process values from the producer before use.

However, by using it, you force yourself to take into account some implementation subtleties that you could normally ignore.

First, keep in mind that you can lose access to the current output buffer any time read() or update() is called, as it may be replaced by an updated buffer from the producer automatically.

Second, to reduce the potential for the aforementioned usage error, this method does not update the output buffer automatically. You need to call update() in order to fetch buffer updates from the producer.

pub fn update(&mut self) -> bool[src]

Update the output buffer

Check if the producer submitted a new data version, and if one is available, update our output buffer to use it. Return a flag that tells you whether such an update was carried out.

Bear in mind that when this happens, you will lose any change that you performed to the output buffer via the output_buffer() interface.

Trait Implementations

impl<T: Debug + Send> Debug for Output<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Output<T>[src]

impl<T> Send for Output<T>[src]

impl<T> Sync for Output<T>[src]

impl<T> Unpin for Output<T>[src]

impl<T> !UnwindSafe for Output<T>[src]

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.