Base object class for RCU-style synchronization for Athena.
More...
#include <RCUObject.h>
|
| bool | endGrace (lock_t &lock, const EventContext &ctx) |
| | Declare that the grace period for a slot is ending.
|
| void | setGrace (lock_t &) |
| | Declare that all slots are in a grace period.
|
| mutex_t & | mutex () |
| | Return the mutex for this object.
|
| virtual void | clearAll (lock_t &)=0 |
| | Delete all objects.
|
| virtual bool | clearOld (lock_t &, size_t nold)=0 |
| | Delete old objects.
|
| void | makeOld (lock_t &lock, size_t garbageSize) |
| | Make existing pending objects old, if possible.
|
|
| std::mutex | m_mutex |
| | The mutex for this object.
|
| IRCUSvc * | m_svc |
| | The service with which we're registered, or null.
|
| std::unique_ptr< RCUObjectGraceSets > | m_graceSets |
| | Holds the current and old grace period bitmasks.
|
| size_t | m_nold |
| | Number of old objects.
|
| std::atomic< bool > | m_dirty |
| | True if there are any objects pending deletion.
|
Base object class for RCU-style synchronization for Athena.
Definition at line 146 of file RCUObject.h.
◆ lock_t
◆ mutex_t
◆ NoObjectEnum
Value to pass to a constructor to mark that we shouldn't allocate an object.
Definition at line 151 of file RCUObject.h.
◆ IRCUObject() [1/4]
| Athena::IRCUObject::IRCUObject |
( |
IRCUSvc & | svc | ) |
|
Constructor, with RCUSvc.
- Parameters
-
| svc | Service with which to register. |
The service will call quiescent at the end of each event.
Definition at line 72 of file RCUObject.cxx.
74 m_graceSets (std::make_unique<RCUObjectGraceSets> (
svc.getNumSlots())),
77{
79}
IRCUSvc * m_svc
The service with which we're registered, or null.
std::atomic< bool > m_dirty
True if there are any objects pending deletion.
std::unique_ptr< RCUObjectGraceSets > m_graceSets
Holds the current and old grace period bitmasks.
size_t m_nold
Number of old objects.
AthROOTErrorHandlerSvc * svc
◆ IRCUObject() [2/4]
| Athena::IRCUObject::IRCUObject |
( |
size_t | nslots | ) |
|
Constructor, with event slot count.
- Parameters
-
| nslots | Number of active event slots. |
This version does not register with a service.
Definition at line 88 of file RCUObject.cxx.
90 m_graceSets (std::make_unique<RCUObjectGraceSets> (nslots)),
93{
94}
◆ IRCUObject() [3/4]
| Athena::IRCUObject::IRCUObject |
( |
IRCUObject && | other | ) |
|
Move constructor.
Allow passing these objects via move.
Definition at line 114 of file RCUObject.cxx.
119{
123 }
124 other.m_dirty =
false;
126 if (
m_svc->remove (&other).isFailure()) {
127 std::abort();
128 }
129 other.m_svc =
nullptr;
131 }
132}
◆ IRCUObject() [4/4]
| Athena::IRCUObject::IRCUObject |
( |
const IRCUObject & | | ) |
|
|
delete |
◆ ~IRCUObject()
| Athena::IRCUObject::~IRCUObject |
( |
| ) |
|
|
virtual |
Destructor.
Remove this object from the service if it has been registered.
Definition at line 102 of file RCUObject.cxx.
103{
104 if (
m_svc &&
m_svc->remove (
this).isFailure())
105 std::abort();
106}
◆ clearAll()
| virtual void Athena::IRCUObject::clearAll |
( |
lock_t & | | ) |
|
|
protectedpure virtual |
◆ clearOld()
| virtual bool Athena::IRCUObject::clearOld |
( |
lock_t & | , |
|
|
size_t | nold ) |
|
protectedpure virtual |
◆ endGrace()
| bool Athena::IRCUObject::endGrace |
( |
lock_t & | lock, |
|
|
const EventContext & | ctx ) |
|
protected |
Declare that the grace period for a slot is ending.
- Parameters
-
| Lock | object (external locking). |
| ctx | Event context for the slot. |
- Returns
- true if any slot is still in a grace period. false if no slots are in a grace period.
The caller must be holding the mutex for this object.
- Parameters
-
| lock | Lock object (external locking). |
| ctx | Event context for the slot. |
- Returns
- true if any slot is still in a grace period. false if no slots are in a grace period.
The caller must be holding the mutex for this object.
Definition at line 165 of file RCUObject.cxx.
◆ makeOld()
| void Athena::IRCUObject::makeOld |
( |
lock_t & | lock, |
|
|
size_t | garbageSize ) |
|
protected |
Make existing pending objects old, if possible.
- Parameters
-
| 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.
Definition at line 193 of file RCUObject.cxx.
194{
195 if (garbageSize &&
m_nold == 0) {
198 }
199}
◆ mutex()
| mutex_t & Athena::IRCUObject::mutex |
( |
| ) |
|
|
protected |
Return the mutex for this object.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ quiescent() [1/2]
| void Athena::IRCUObject::quiescent |
( |
| ) |
|
Declare the current event slot of this object to be quiescent.
This will take out a lock and possibly trigger object cleanup.
◆ quiescent() [2/2]
| void Athena::IRCUObject::quiescent |
( |
const EventContext & | ctx | ) |
|
Declare the event slot ctx of this object to be quiescent.
- Parameters
-
This will take out a lock and possibly trigger object cleanup.
◆ quiescentOol()
| void Athena::IRCUObject::quiescentOol |
( |
const EventContext & | ctx | ) |
|
|
private |
Out-of-line part of quiescent().
Definition at line 138 of file RCUObject.cxx.
139{
140
146 }
150 }
152 }
153}
virtual void clearAll(lock_t &)=0
Delete all objects.
virtual bool clearOld(lock_t &, size_t nold)=0
Delete old objects.
std::unique_lock< mutex_t > lock_t
bool endGrace(lock_t &lock, const EventContext &ctx)
Declare that the grace period for a slot is ending.
std::mutex m_mutex
The mutex for this object.
◆ setGrace()
| void Athena::IRCUObject::setGrace |
( |
lock_t & | | ) |
|
|
protected |
Declare that all slots are in a grace period.
- Parameters
-
| Lock | object (external locking). |
The caller must be holding the mutex for this object.
Definition at line 177 of file RCUObject.cxx.
◆ m_dirty
| std::atomic<bool> Athena::IRCUObject::m_dirty |
|
private |
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 300 of file RCUObject.h.
◆ m_graceSets
Holds the current and old grace period bitmasks.
Split off into a separate object to reduce header dependencies.
Definition at line 292 of file RCUObject.h.
◆ m_mutex
| std::mutex Athena::IRCUObject::m_mutex |
|
private |
The mutex for this object.
Definition at line 285 of file RCUObject.h.
◆ m_nold
| size_t Athena::IRCUObject::m_nold |
|
private |
Number of old objects.
The objects at the end of the garbage list are old.
Definition at line 296 of file RCUObject.h.
◆ m_svc
The service with which we're registered, or null.
Definition at line 288 of file RCUObject.h.
The documentation for this class was generated from the following files: