cds
2.3.2
|
User-space general-purpose RCU with deferred (buffered) reclamation. More...
#include <cds/urcu/general_buffered.h>
Public Types | |
typedef general_buffered_tag | rcu_tag |
RCU tag. | |
typedef Buffer | buffer_type |
Buffer type. | |
typedef Lock | lock_type |
Lock type. | |
typedef Backoff | back_off |
Back-off type. | |
typedef base_class::thread_gc | thread_gc |
Thread-side RCU part. | |
typedef thread_gc::scoped_lock | scoped_lock |
Access lock class. | |
Public Member Functions | |
virtual void | retire_ptr (retired_ptr &p) override |
Retire p pointer. More... | |
template<typename ForwardIterator > | |
void | batch_retire (ForwardIterator itFirst, ForwardIterator itLast) |
Retires the pointer chain [itFirst , itLast ) | |
template<typename Func > | |
void | batch_retire (Func e) |
Retires the pointer chain until Func returns nullptr retired pointer. | |
void | synchronize () |
Wait to finish a grace period and then clear the buffer. | |
size_t | capacity () const |
Returns internal buffer capacity. | |
Static Public Member Functions | |
static general_buffered * | instance () |
Returns singleton instance. | |
static bool | isUsed () |
Checks if the singleton is created and ready to use. | |
static void | Construct (size_t nBufferCapacity=256) |
Creates singleton object. More... | |
static void | Destruct (bool bDetachAll=false) |
Destroys singleton object. | |
User-space general-purpose RCU with deferred (buffered) reclamation.
This URCU implementation contains an internal buffer where retired objects are accumulated. When the buffer becomes full, the RCU synchronize
function is called that waits until all reader/updater threads end up their read-side critical sections, i.e. until the RCU quiescent state will come. After that the buffer and all retired objects are freed. This synchronization cycle may be called in any thread that calls retire_ptr
function.
The Buffer
contains items of epoch_retired_ptr type and it should support a queue interface with three function:
bool push( retired_ptr& p )
- places the retired pointer p
into queue. If the function returns false
it means that the buffer is full and RCU synchronization cycle must be processed.bool pop( retired_ptr& p )
- pops queue's head item into p
parameter; if the queue is empty this function must return false
size_t size()
- returns queue's item count.The buffer is considered as full if push()
returns false
or the buffer size reaches the RCU threshold.
There is a wrapper gc<general_buffered> for general_buffered
class that provides unified RCU interface. You should use this wrapper class instead general_buffered
Template arguments:
Buffer
- buffer type. Default is cds::container::VyukovMPMCCycleQueue
Lock
- mutex type, default is std::mutex
Backoff
- back-off schema, default is cds::backoff::Default
|
inlinestatic |
Creates singleton object.
The nBufferCapacity
parameter defines RCU threshold.
|
inlineoverridevirtual |
Retire p
pointer.
The method pushes p
pointer to internal buffer. When the buffer becomes full synchronize function is called to wait for the end of grace period and then to free all pointers from the buffer.