[][src]Struct triple_buffer::Input

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

Producer interface to the triple buffer

The producer of data can use this struct to submit updates to the triple buffer whenever he likes. These updates are nonblocking: a collision between the producer and the consumer will result in cache contention, but deadlocks and scheduling-induced slowdowns cannot happen.

Methods

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

pub fn write(&mut self, value: T)[src]

Write a new value into the triple buffer

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

Check if the consumer has fetched our last submission yet

This method is only intended for diagnostics purposes. Please do not let it inform your decision of sending or not sending a value, 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 raw_input_buffer(&mut self) -> &mut T[src]

Get raw access to the input buffer

This advanced interface allows you to update the input buffer in place, which can in some case improve performance by avoiding to create values of type T repeatedy when this is an expensive process.

However, by opting into it, you force yourself to take into account subtle implementation details which you could normally ignore.

First, the buffer does not contain the last value that you sent (which is now into the hands of the consumer). In fact, the consumer is allowed to write complete garbage into it if it feels so inclined. All you can safely assume is that it contains a valid value of type T.

Second, we do not send updates automatically. You need to call raw_publish() in order to propagate a buffer update to the consumer. Alternative designs based on Drop were considered, but ultimately deemed too magical for the target audience of this method.

To use this method, you have to enable the crate's raw feature

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

Unconditionally publish an update, checking for overwrites

After updating the input buffer using raw_input_buffer(), you can use this method to publish your updates to the consumer. It will send back an output flag which tells you whether an unread value was overwritten.

To use this method, you have to enable the crate's raw feature

Trait Implementations

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

Auto Trait Implementations

impl<T> Send for Input<T>

impl<T> Sync for Input<T>

impl<T> Unpin for Input<T>

impl<T> !UnwindSafe for Input<T>

impl<T> !RefUnwindSafe for Input<T>

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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