ATLAS Offline Software
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Athena::RCUObject< T > Class Template Reference

Wrapper object controlled by RCU synchonization. More...

#include <RCUObject.h>

Inheritance diagram for Athena::RCUObject< T >:
Collaboration diagram for Athena::RCUObject< T >:

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
 
RCUObjectoperator= (const RCUObject &)=delete
 
RCUObjectoperator= (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_tlock_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_tmutex ()
 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...
 
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...
 

Friends

template<class U >
class RCUReadQuiesce
 
template<class U >
class RCURead
 
template<class U >
class RCUUpdate
 

Detailed Description

template<class T>
class Athena::RCUObject< T >

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.

Member Typedef Documentation

◆ lock_t

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

Definition at line 213 of file RCUObject.h.

◆ mutex_t

typedef std::mutex Athena::IRCUObject::mutex_t
protectedinherited

Definition at line 212 of file RCUObject.h.

◆ Read_t

template<class T >
typedef RCURead<T> Athena::RCUObject< T >::Read_t

Definition at line 324 of file RCUObject.h.

◆ ReadQuiesce_t

template<class T >
typedef RCUReadQuiesce<T> Athena::RCUObject< T >::ReadQuiesce_t

Definition at line 325 of file RCUObject.h.

◆ Update_t

template<class T >
typedef RCUUpdate<T> Athena::RCUObject< T >::Update_t

Definition at line 326 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

◆ RCUObject() [1/5]

template<class T >
template<typename... Args>
Athena::RCUObject< T >::RCUObject ( IRCUSvc svc,
Args &&...  args 
)

Constructor, with RCUSvc.

Parameters
svcService with which to register.
args...Additional arguments to pass to the T constructor.

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

◆ RCUObject() [2/5]

template<class T >
template<typename... Args>
Athena::RCUObject< T >::RCUObject ( size_t  nslots,
Args &&...  args 
)

Constructor, with number of slots.

Parameters
nslotsNumber of event slots.
args...Additional arguments to pass to the T constructor.

◆ RCUObject() [3/5]

template<class T >
Athena::RCUObject< T >::RCUObject ( IRCUSvc svc,
NoObjectEnum   
)

Constructor, with RCUSvc.

Parameters
svcService with which to register.

The service will call quiescent at the end of each event. No current object will be created.

◆ RCUObject() [4/5]

template<class T >
Athena::RCUObject< T >::RCUObject ( RCUObject< T > &&  other)

Move constructor.

Allow passing these objects via move.

◆ RCUObject() [5/5]

template<class T >
Athena::RCUObject< T >::RCUObject ( const RCUObject< T > &  )
delete

Member Function Documentation

◆ clearAll()

template<class T >
virtual void Athena::RCUObject< T >::clearAll ( lock_t )
overrideprivatevirtual

Delete all objects.

Parameters
Lockobject (external locking).

The caller must be holding the mutex for this object.

Implements Athena::IRCUObject.

◆ clearOld()

template<class T >
virtual bool Athena::RCUObject< T >::clearOld ( lock_t ,
size_t  nold 
)
overrideprivatevirtual

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.

Implements Athena::IRCUObject.

◆ discard() [1/2]

template<class T >
void Athena::RCUObject< T >::discard ( lock_t ,
std::unique_ptr< const T >  p 
)
protected

Queue an object for later deletion.

Parameters
lockLock object (external locking).
pThe object to delete.

◆ discard() [2/2]

template<class T >
void Athena::RCUObject< T >::discard ( std::unique_ptr< const T >  p)

Queue an object for later deletion.

Parameters
pThe 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).

◆ endGrace() [1/2]

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

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 
)
protectedinherited

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 
)
protectedinherited

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 ( )
protectedinherited

Return the mutex for this object.

◆ operator=() [1/2]

template<class T >
RCUObject& Athena::RCUObject< T >::operator= ( const RCUObject< T > &  )
delete

◆ operator=() [2/2]

template<class T >
RCUObject& Athena::RCUObject< T >::operator= ( RCUObject< T > &&  )
delete

◆ quiescent() [1/2]

void Athena::IRCUObject::quiescent ( )
inherited

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)
inherited

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.

◆ reader()

template<class T >
Read_t Athena::RCUObject< T >::reader ( ) const

Return a reader for this RCUObject.

◆ readerQuiesce() [1/3]

template<class T >
ReadQuiesce_t Athena::RCUObject< T >::readerQuiesce ( )

Return a reader for this RCUObject.

When destroyed, this reader will declare the RCUObject as quiescent

This version will read the global event context.

◆ readerQuiesce() [2/3]

template<class T >
ReadQuiesce_t Athena::RCUObject< T >::readerQuiesce ( const EventContext &&  ctx)
delete

◆ readerQuiesce() [3/3]

template<class T >
ReadQuiesce_t Athena::RCUObject< T >::readerQuiesce ( const EventContext &  ctx)

Return a reader for this RCUObject.

When destroyed, this reader will declare the RCUObject as quiescent

Parameters
ctxThe event context (must not be a temporary).

◆ setGrace()

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

Declare that all slots are in a grace period.

Parameters
Lockobject (external locking).

The caller must be holding the mutex for this object.

◆ updater() [1/3]

template<class T >
Update_t Athena::RCUObject< T >::updater ( )

Return an updater for this RCUObject.

This version will read the global event context.

◆ updater() [2/3]

template<class T >
Update_t Athena::RCUObject< T >::updater ( const EventContext &&  ctx)
delete

◆ updater() [3/3]

template<class T >
Update_t Athena::RCUObject< T >::updater ( const EventContext &  ctx)

Return an updater for this RCUObject.

Parameters
ctxThe event context (must not be a temporary).

Friends And Related Function Documentation

◆ RCURead

template<class T >
template<class U >
friend class RCURead
friend

Definition at line 461 of file RCUObject.h.

◆ RCUReadQuiesce

template<class T >
template<class U >
friend class RCUReadQuiesce
friend

Definition at line 460 of file RCUObject.h.

◆ RCUUpdate

template<class T >
template<class U >
friend class RCUUpdate
friend

Definition at line 462 of file RCUObject.h.

Member Data Documentation

◆ m_dirty

std::atomic<bool> Athena::IRCUObject::m_dirty
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.

◆ m_garbage

template<class T >
std::deque<std::unique_ptr<const T> > Athena::RCUObject< T >::m_garbage
private

List of objects pending cleanup.

Definition at line 471 of file RCUObject.h.

◆ m_grace

boost::dynamic_bitset Athena::IRCUObject::m_grace
privateinherited

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
privateinherited

The mutex for this object.

Definition at line 293 of file RCUObject.h.

◆ m_nold

size_t Athena::IRCUObject::m_nold
privateinherited

Number of old objects.

The objects at the end of the garbage list are old.

Definition at line 306 of file RCUObject.h.

◆ m_obj

template<class T >
std::atomic<const T*> Athena::RCUObject< T >::m_obj
private

Pointer to the current object.

Definition at line 468 of file RCUObject.h.

◆ m_objref

template<class T >
std::unique_ptr<T> Athena::RCUObject< T >::m_objref
private

Owning reference to the current object.

Definition at line 465 of file RCUObject.h.

◆ m_oldGrace

boost::dynamic_bitset Athena::IRCUObject::m_oldGrace
privateinherited

Same thing, for the objects marked as old.

Definition at line 302 of file RCUObject.h.

◆ m_svc

IRCUSvc* Athena::IRCUObject::m_svc
privateinherited

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 file:
Athena::IRCUObject::NoObject
@ NoObject
Definition: RCUObject.h:150