Triple buffer based on a single atomic variable, that guards against the consumer thread using old values. 更多...
#include <MultiBufferResource.h>
继承自 Chaos::IBufferResource< ResourceType > .
Public 成员函数 | |
| virtual ResourceType * | AccessProducerBuffer () override |
| Get the current producer buffer for writing. 更多... | |
| FGuardedTripleBuffer () | |
| This class implements a circular buffer access pattern, such that during normal serial operation each buffer will be used. 更多... | |
| virtual void | FlipProducer () |
| Make the current producer buffer available to the consumer thread. 更多... | |
| virtual const ResourceType * | GetConsumerBuffer () const override |
| Get an updated buffer for the consuming thread to read from. 更多... | |
| virtual const ResourceType * | GetProducerBuffer () const override |
| Get the current producer buffer. 更多... | |
| const ResourceType * | PeekConsumerBuffer () const |
| Get access to the currently held consumer buffer, ignoring whether it's already been consumed. | |
Triple buffer based on a single atomic variable, that guards against the consumer thread using old values.
Not thread-safe, requires external locks.
|
inline |
This class implements a circular buffer access pattern, such that during normal serial operation each buffer will be used.
However, we can alter how we use the API to use only 2 or 1 buffer:
SERIAL ACCESS BUFFER USE - NORMAL OPERATION: P C I Init: 0, 1, 2
AccP: *0, 1, 2 - *write access Flip: 2, 1, 0 Cons: 2, ^0, 1 - ^read access
AccP: *2, 0, 1 Flip: 1, 0, 2 Cons: 1, ^2, 0
AccP: *1, 2, 0 Flip: 0, 2, 1 Cons: 0, ^1, 2
SERIAL ACCESS BUFFER USE - DOUBLE BUFFER EMULATION: Init: 0, 1, 2
AccP: *0, 1, 2 - *write access Flip: 2, 1, 0 Cons: 2, ^0, 1 - ^read access Flip: 1, 0, 2 <- Add an extra flip and only use 2 buffers.
AccP: *1, 0, 2 Flip: 2, 0, 1 Cons: 2, ^1, 0 Flip: 0, 1, 2
SERIAL ACCESS BUFFER USE - SINGLE BUFFER EMULATION: Init: 0, 1, 2
AccP: *0, 1, 2 - *write access Flip: 2, 1, 0 Cons: 2, ^0, 1 - ^read access Cons: 2, 1, 0 <- Add an extra consume... Flip: 0, 1, 2 <- and an extra flip and only use 1 buffer.
|
inlineoverridevirtual |
Get the current producer buffer for writing.
The returned pointer will never be null.
This function should only be called by the producer thread.
|
inlinevirtual |
Make the current producer buffer available to the consumer thread.
This function should only be called by the producer thread.
|
inlineoverridevirtual |
Get an updated buffer for the consuming thread to read from.
The returned pointer may be null if the producer thread hasn't done an update since the last time this function was called.
This function should only be called by the consumer thread.
|
inlineoverridevirtual |
Get the current producer buffer.
The returned pointer will never be null.
This function should only be called by the producer thread.