ATLAS Offline Software
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Athena::IRCUObject Class Referenceabstract

Base object class for RCU-style synchronization for Athena. More...

#include <RCUObject.h>

Inheritance diagram for Athena::IRCUObject:
Collaboration diagram for Athena::IRCUObject:

Public Types

enum  NoObjectEnum { NoObject }
 Value to pass to a constructor to mark that we shouldn't allocate an object. More...
 

Public Member Functions

 IRCUObject (IRCUSvc &svc)
 Constructor, with RCUSvc. More...
 
 IRCUObject (size_t nslots)
 Constructor, with event slot count. More...
 
 IRCUObject (IRCUObject &&other)
 Move constructor. More...
 
 IRCUObject (const IRCUObject &)=delete
 
IRCUObjectoperator= (const IRCUObject &)=delete
 
IRCUObjectoperator= (IRCUObject &&)=delete
 
virtual ~IRCUObject ()
 Destructor. 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_tlock_t
 

Protected Member Functions

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_tmutex ()
 Return the mutex for this object. More...
 
virtual void clearAll (lock_t &)=0
 Delete all objects. More...
 
virtual bool clearOld (lock_t &, size_t nold)=0
 Delete old objects. More...
 
void makeOld (lock_t &lock, size_t garbageSize)
 Make existing pending objects old, if possible. More...
 

Private Member Functions

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::mutex m_mutex
 The mutex for this object. More...
 
IRCUSvcm_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...
 

Detailed Description

Base object class for RCU-style synchronization for Athena.

Definition at line 145 of file RCUObject.h.

Member Typedef Documentation

◆ lock_t

typedef std::unique_lock<mutex_t> Athena::IRCUObject::lock_t
protected

Definition at line 213 of file RCUObject.h.

◆ mutex_t

typedef std::mutex Athena::IRCUObject::mutex_t
protected

Definition at line 212 of file RCUObject.h.

Member Enumeration Documentation

◆ NoObjectEnum

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.

150 { NoObject };

Constructor & Destructor Documentation

◆ IRCUObject() [1/4]

Athena::IRCUObject::IRCUObject ( IRCUSvc svc)

Constructor, with RCUSvc.

Parameters
svcService with which to register.

The service will call quiescent at the end of each event.

Definition at line 26 of file RCUObject.cxx.

27  : m_svc (&svc),
28  m_grace (svc.getNumSlots()),
29  m_oldGrace (svc.getNumSlots()),
30  m_nold(0),
31  m_dirty(false)
32 {
33  m_svc->add (this);
34 }

◆ IRCUObject() [2/4]

Athena::IRCUObject::IRCUObject ( size_t  nslots)

Constructor, with event slot count.

Parameters
nslotsNumber of active event slots.

This version does not register with a service.

Definition at line 43 of file RCUObject.cxx.

44  : m_svc (nullptr),
45  m_grace (nslots),
46  m_oldGrace (nslots),
47  m_nold(0),
48  m_dirty(false)
49 {
50 }

◆ IRCUObject() [3/4]

Athena::IRCUObject::IRCUObject ( IRCUObject &&  other)

Move constructor.

Allow passing these objects via move.

Definition at line 70 of file RCUObject.cxx.

71  : m_svc (other.m_svc),
72  m_grace (std::move (other.m_grace)),
73  m_oldGrace (std::move (other.m_oldGrace)),
74  m_nold (other.m_nold),
75  m_dirty (false)
76 {
77  other.m_nold = 0;
78  if (other.m_dirty) {
79  m_dirty = true;
80  }
81  other.m_dirty = false;
82  if (m_svc) {
83  if (m_svc->remove (&other).isFailure()) {
84  std::abort();
85  }
86  other.m_svc = nullptr;
87  m_svc->add (this);
88  }
89 }

◆ 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 58 of file RCUObject.cxx.

59 {
60  if (m_svc && m_svc->remove (this).isFailure())
61  std::abort();
62 }

Member Function Documentation

◆ clearAll()

virtual void Athena::IRCUObject::clearAll ( lock_t )
protectedpure virtual

Delete all objects.

Parameters
Lockobject (external locking).

The caller must be holding the mutex for this object.

Implemented in Athena::RCUObject< T >.

◆ clearOld()

virtual bool Athena::IRCUObject::clearOld ( lock_t ,
size_t  nold 
)
protectedpure virtual

Delete old objects.

Parameters
Lockobject (external locking).
noldNumber 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.

Implemented in Athena::RCUObject< T >.

◆ endGrace() [1/2]

bool Athena::IRCUObject::endGrace ( lock_t ,
const EventContext &  ctx,
boost::dynamic_bitset<> &  grace 
) const
private

Declare that the grace period for a slot is ending.

Parameters
Lockobject (external locking).
ctxEvent context for the slot.
graceBitmask tracking grace periods.
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.

◆ endGrace() [2/2]

bool Athena::IRCUObject::endGrace ( lock_t lock,
const EventContext &  ctx 
)
protected

Declare that the grace period for a slot is ending.

Parameters
Lockobject (external locking).
ctxEvent 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.

◆ makeOld()

void Athena::IRCUObject::makeOld ( lock_t lock,
size_t  garbageSize 
)
protected

Make existing pending objects old, if possible.

Parameters
lockLock object (external locking).
garbageSizePresent 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.

◆ mutex()

mutex_t& Athena::IRCUObject::mutex ( )
protected

Return the mutex for this object.

◆ operator=() [1/2]

IRCUObject& Athena::IRCUObject::operator= ( const IRCUObject )
delete

◆ operator=() [2/2]

IRCUObject& Athena::IRCUObject::operator= ( IRCUObject &&  )
delete

◆ 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
ctxThe event context.

This will take out a lock and possibly trigger object cleanup.

◆ setGrace()

void Athena::IRCUObject::setGrace ( lock_t )
protected

Declare that all slots are in a grace period.

Parameters
Lockobject (external locking).

The caller must be holding the mutex for this object.

Member Data Documentation

◆ 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 310 of file RCUObject.h.

◆ m_grace

boost::dynamic_bitset Athena::IRCUObject::m_grace
private

Bit[i] set means that slot i is in a grace period.

Definition at line 299 of file RCUObject.h.

◆ m_mutex

std::mutex Athena::IRCUObject::m_mutex
private

The mutex for this object.

Definition at line 293 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 306 of file RCUObject.h.

◆ m_oldGrace

boost::dynamic_bitset Athena::IRCUObject::m_oldGrace
private

Same thing, for the objects marked as old.

Definition at line 302 of file RCUObject.h.

◆ m_svc

IRCUSvc* Athena::IRCUObject::m_svc
private

The service with which we're registered, or null.

Definition at line 296 of file RCUObject.h.


The documentation for this class was generated from the following files:
Athena::IRCUObject::m_dirty
std::atomic< bool > m_dirty
True if there are any objects pending deletion.
Definition: RCUObject.h:310
Athena::IRCUObject::m_svc
IRCUSvc * m_svc
The service with which we're registered, or null.
Definition: RCUObject.h:296
Athena::IRCUSvc::add
virtual void add(IRCUObject *obj)=0
Add a new RCU object to the set being managed.
Athena::IRCUObject::m_nold
size_t m_nold
Number of old objects.
Definition: RCUObject.h:306
Athena::IRCUObject::m_grace
boost::dynamic_bitset m_grace
Bit[i] set means that slot i is in a grace period.
Definition: RCUObject.h:299
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
Athena::IRCUSvc::remove
virtual StatusCode remove(IRCUObject *obj)=0
Remove an object from the service.
Athena::IRCUObject::NoObject
@ NoObject
Definition: RCUObject.h:150
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
Athena::IRCUObject::m_oldGrace
boost::dynamic_bitset m_oldGrace
Same thing, for the objects marked as old.
Definition: RCUObject.h:302