[−][src]Struct triple_buffer::Output
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
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]
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,
pub 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, 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.
pub 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>,