Struct triple_buffer::Output[][src]

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

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

Access the latest value from the triple buffer

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.

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.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.