#include <AspectPool.h>
This class is responsible for providing a buffer for communicating aspects between threads, such that only the most up to date aspect is kept, and the previous one is reused to send the next update. This is similar to triple buffering.
Protected Attributes | |
AspectPool & | pool |
AtomicInt | latestID |
-1 or aspect ID of the last version sent More... | |
AtomicInt | availableID |
-1 or aspect ID available to send the next version More... | |
Public Member Functions | |
AspectBuffer (AspectPool &pool) | |
~AspectBuffer () | |
AspectRef | allocate () |
Allocate an aspect ID to prepare the next version, reusing a recent one if possible. More... | |
void | push (AspectRef id) |
Send a new version, overriding the latest if it was not already received (in which case it can be "recycled" using allocate) More... | |
bool | pop (AspectRef &id) |
Receive the latest version, return true if one is available, or false otherwise (in which case id is unchanged) More... | |
void | clear () |
|
protected |
-1 or aspect ID available to send the next version
|
protected |
-1 or aspect ID of the last version sent
|
protected |
sofa::core::objectmodel::AspectBuffer::AspectBuffer | ( | AspectPool & | pool | ) |
sofa::core::objectmodel::AspectBuffer::~AspectBuffer | ( | ) |
AspectRef sofa::core::objectmodel::AspectBuffer::allocate | ( | ) |
Allocate an aspect ID to prepare the next version, reusing a recent one if possible.
void sofa::core::objectmodel::AspectBuffer::clear | ( | ) |
Clear the buffers This must be called before either the AspectPool or this buffer is deleted
Receive the latest version, return true if one is available, or false otherwise (in which case id is unchanged)
void sofa::core::objectmodel::AspectBuffer::push | ( | AspectRef | id | ) |
Send a new version, overriding the latest if it was not already received (in which case it can be "recycled" using allocate)