ATLAS Offline Software
|
Wrapper object controlled by RCU synchonization. More...
#include <RCUObject.h>
Public Types | |
typedef RCURead< T > | Read_t |
typedef RCUReadQuiesce< T > | ReadQuiesce_t |
typedef RCUUpdate< T > | Update_t |
enum | NoObjectEnum { NoObject } |
Value to pass to a constructor to mark that we shouldn't allocate an object. More... | |
Public Member Functions | |
template<typename... Args> | |
RCUObject (IRCUSvc &svc, Args &&... args) | |
Constructor, with RCUSvc. More... | |
template<typename... Args> | |
RCUObject (size_t nslots, Args &&... args) | |
Constructor, with number of slots. More... | |
RCUObject (IRCUSvc &svc, NoObjectEnum) | |
Constructor, with RCUSvc. More... | |
RCUObject (RCUObject &&other) | |
Move constructor. More... | |
RCUObject (const RCUObject &)=delete | |
RCUObject & | operator= (const RCUObject &)=delete |
RCUObject & | operator= (RCUObject &&)=delete |
Read_t | reader () const |
Return a reader for this RCUObject . More... | |
ReadQuiesce_t | readerQuiesce () |
Return a reader for this RCUObject . More... | |
ReadQuiesce_t | readerQuiesce (const EventContext &ctx) |
Return a reader for this RCUObject . More... | |
ReadQuiesce_t | readerQuiesce (const EventContext &&ctx)=delete |
Update_t | updater () |
Return an updater for this RCUObject . More... | |
Update_t | updater (const EventContext &ctx) |
Return an updater for this RCUObject . More... | |
Update_t | updater (const EventContext &&ctx)=delete |
void | discard (std::unique_ptr< const T > p) |
Queue an object for later deletion. More... | |
void | quiescent () |
Declare the current event slot of this object to be quiescent. More... | |
void | quiescent (const EventContext &ctx) |
Declare the event slot ctx of this object to be quiescent. More... | |
Protected Types | |
typedef std::mutex | mutex_t |
typedef std::unique_lock< mutex_t > | lock_t |
Protected Member Functions | |
void | discard (lock_t &, std::unique_ptr< const T > p) |
Queue an object for later deletion. More... | |
bool | endGrace (lock_t &lock, const EventContext &ctx) |
Declare that the grace period for a slot is ending. More... | |
void | setGrace (lock_t &) |
Declare that all slots are in a grace period. More... | |
mutex_t & | mutex () |
Return the mutex for this object. More... | |
void | makeOld (lock_t &lock, size_t garbageSize) |
Make existing pending objects old, if possible. More... | |
Private Member Functions | |
virtual void | clearAll (lock_t &) override |
Delete all objects. More... | |
virtual bool | clearOld (lock_t &, size_t nold) override |
Delete old objects. More... | |
bool | endGrace (lock_t &, const EventContext &ctx, boost::dynamic_bitset<> &grace) const |
Declare that the grace period for a slot is ending. More... | |
Private Attributes | |
std::unique_ptr< T > | m_objref |
Owning reference to the current object. More... | |
std::atomic< const T * > | m_obj |
Pointer to the current object. More... | |
std::deque< std::unique_ptr< const T > > | m_garbage |
List of objects pending cleanup. More... | |
std::mutex | m_mutex |
The mutex for this object. More... | |
IRCUSvc * | m_svc |
The service with which we're registered, or null. More... | |
boost::dynamic_bitset | m_grace |
Bit[i] set means that slot i is in a grace period. More... | |
boost::dynamic_bitset | m_oldGrace |
Same thing, for the objects marked as old. More... | |
size_t | m_nold |
Number of old objects. More... | |
std::atomic< bool > | m_dirty |
True if there are any objects pending deletion. More... | |
Friends | |
template<class U > | |
class | RCUReadQuiesce |
template<class U > | |
class | RCURead |
template<class U > | |
class | RCUUpdate |
Wrapper object controlled by RCU synchonization.
See the comments at the top of the file for complete comments.
Definition at line 320 of file RCUObject.h.
|
protectedinherited |
Definition at line 213 of file RCUObject.h.
|
protectedinherited |
Definition at line 212 of file RCUObject.h.
typedef RCURead<T> Athena::RCUObject< T >::Read_t |
Definition at line 324 of file RCUObject.h.
typedef RCUReadQuiesce<T> Athena::RCUObject< T >::ReadQuiesce_t |
Definition at line 325 of file RCUObject.h.
typedef RCUUpdate<T> Athena::RCUObject< T >::Update_t |
Definition at line 326 of file RCUObject.h.
|
inherited |
Value to pass to a constructor to mark that we shouldn't allocate an object.
Enumerator | |
---|---|
NoObject |
Definition at line 150 of file RCUObject.h.
Athena::RCUObject< T >::RCUObject | ( | IRCUSvc & | svc, |
Args &&... | args | ||
) |
Constructor, with RCUSvc.
svc | Service with which to register. |
args... | Additional arguments to pass to the T constructor. |
The service will call quiescent
at the end of each event.
Athena::RCUObject< T >::RCUObject | ( | size_t | nslots, |
Args &&... | args | ||
) |
Constructor, with number of slots.
nslots | Number of event slots. |
args... | Additional arguments to pass to the T constructor. |
Athena::RCUObject< T >::RCUObject | ( | IRCUSvc & | svc, |
NoObjectEnum | |||
) |
Constructor, with RCUSvc.
svc | Service with which to register. |
The service will call quiescent
at the end of each event. No current object will be created.
Athena::RCUObject< T >::RCUObject | ( | RCUObject< T > && | other | ) |
Move constructor.
Allow passing these objects via move.
|
delete |
|
overrideprivatevirtual |
Delete all objects.
Lock | object (external locking). |
The caller must be holding the mutex for this object.
Implements Athena::IRCUObject.
|
overrideprivatevirtual |
Delete old objects.
Lock | object (external locking). |
nold | Number of old objects to delete. |
The caller must be holding the mutex for this object. Returns true if there are no more objects pending deletion.
Implements Athena::IRCUObject.
|
protected |
Queue an object for later deletion.
lock | Lock object (external locking). |
p | The object to delete. |
void Athena::RCUObject< T >::discard | ( | std::unique_ptr< const T > | p | ) |
Queue an object for later deletion.
p | The object to delete. |
The object p
will be queued for deletion once a grace period has passed for all slots. In contrast to using updater
, this does not change the current object. It also does not mark the current slot as having completed the grace period (so this can be called by a thread running outside of a slot context).
|
privateinherited |
Declare that the grace period for a slot is ending.
Lock | object (external locking). |
ctx | Event context for the slot. |
grace | Bitmask tracking grace periods. |
The caller must be holding the mutex for this object.
Declare that the grace period for a slot is ending.
Lock | object (external locking). |
ctx | Event context for the slot. |
The caller must be holding the mutex for this object.
|
protectedinherited |
Make existing pending objects old, if possible.
lock | Lock object (external locking). |
garbageSize | Present number of objects pending deletion. |
A new object is about to be added to the list of objects pending deletion. If there are any existing pending objects and there are no existing old objects, make the current pending objects old.
|
protectedinherited |
Return the mutex for this object.
|
delete |
|
delete |
|
inherited |
Declare the current event slot of this object to be quiescent.
This will take out a lock and possibly trigger object cleanup.
|
inherited |
Declare the event slot ctx
of this object to be quiescent.
ctx | The event context. |
This will take out a lock and possibly trigger object cleanup.
Read_t Athena::RCUObject< T >::reader | ( | ) | const |
Return a reader for this RCUObject
.
ReadQuiesce_t Athena::RCUObject< T >::readerQuiesce | ( | ) |
|
delete |
ReadQuiesce_t Athena::RCUObject< T >::readerQuiesce | ( | const EventContext & | ctx | ) |
|
protectedinherited |
Declare that all slots are in a grace period.
Lock | object (external locking). |
The caller must be holding the mutex for this object.
Update_t Athena::RCUObject< T >::updater | ( | ) |
Return an updater for this RCUObject
.
This version will read the global event context.
|
delete |
Update_t Athena::RCUObject< T >::updater | ( | const EventContext & | ctx | ) |
Return an updater for this RCUObject
.
ctx | The event context (must not be a temporary). |
Definition at line 461 of file RCUObject.h.
Definition at line 460 of file RCUObject.h.
Definition at line 462 of file RCUObject.h.
|
privateinherited |
True if there are any objects pending deletion.
Used to avoid taking the lock in quiescent() if there's nothing to do.
Definition at line 310 of file RCUObject.h.
|
private |
List of objects pending cleanup.
Definition at line 471 of file RCUObject.h.
|
privateinherited |
Bit[i] set means that slot i is in a grace period.
Definition at line 299 of file RCUObject.h.
|
privateinherited |
The mutex for this object.
Definition at line 293 of file RCUObject.h.
|
privateinherited |
Number of old objects.
The objects at the end of the garbage list are old.
Definition at line 306 of file RCUObject.h.
|
private |
Pointer to the current object.
Definition at line 468 of file RCUObject.h.
|
private |
Owning reference to the current object.
Definition at line 465 of file RCUObject.h.
|
privateinherited |
Same thing, for the objects marked as old.
Definition at line 302 of file RCUObject.h.
|
privateinherited |
The service with which we're registered, or null.
Definition at line 296 of file RCUObject.h.