Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CxxUtils::SimpleUpdater< T > Class Template Reference

Simple (non-deleting) Updater implementation. More...

#include <SimpleUpdater.h>

Collaboration diagram for CxxUtils::SimpleUpdater< T >:

Classes

struct  Context_t
 Context object. More...
 

Public Member Functions

 SimpleUpdater ()=default
 We need a default constructor. More...
 
 SimpleUpdater (SimpleUpdater &&other)
 Move constructor. More...
 
const T & get () const
 Return a reference to the current object. More...
 
void update (std::unique_ptr< T > p, const Context_t &)
 Install a new object. More...
 
void discard (std::unique_ptr< T > p)
 Queue an object for later deletion. More...
 
void quiescent (const Context_t &)
 Mark that an event slot is not referencing this object. More...
 
void clean ()
 Delete all objects we're managing except for the current one. More...
 
void swap (SimpleUpdater &other)
 Swap this object with another. More...
 

Static Public Member Functions

static const Context_t defaultContext ()
 Return the current event context. More...
 

Private Attributes

std::atomic< const T * > m_obj = 0
 Pointer to the current object. More...
 
std::vector< std::unique_ptr< T > > m_objs
 List of all allocated objects. More...
 

Detailed Description

template<class T>
class CxxUtils::SimpleUpdater< T >

Simple (non-deleting) Updater implementation.

This is a simple implementation of the Updater interface as described in ConcurrentRangeMap that does not delete any memory until the SimpleUpdater itself is deleted. This can be useful for, say, a ConcurrentStrMap if you have a good initial guess for the size of the table.

Definition at line 36 of file SimpleUpdater.h.

Constructor & Destructor Documentation

◆ SimpleUpdater() [1/2]

template<class T >
CxxUtils::SimpleUpdater< T >::SimpleUpdater ( )
default

We need a default constructor.

◆ SimpleUpdater() [2/2]

template<class T >
CxxUtils::SimpleUpdater< T >::SimpleUpdater ( SimpleUpdater< T > &&  other)

Move constructor.

Member Function Documentation

◆ clean()

template<class T >
void CxxUtils::SimpleUpdater< T >::clean ( )

Delete all objects we're managing except for the current one.

This is NOT concurrency-safe. No other threads may be accessing the objects managed here.

◆ defaultContext()

template<class T >
static const Context_t CxxUtils::SimpleUpdater< T >::defaultContext ( )
static

Return the current event context.

◆ discard()

template<class T >
void CxxUtils::SimpleUpdater< T >::discard ( std::unique_ptr< 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 update, this does not change the current object.

◆ get()

template<class T >
const T& CxxUtils::SimpleUpdater< T >::get ( ) const

Return a reference to the current object.

◆ quiescent()

template<class T >
void CxxUtils::SimpleUpdater< T >::quiescent ( const Context_t )

Mark that an event slot is not referencing this object.

A no-op for SimpleUpdater.

◆ swap()

template<class T >
void CxxUtils::SimpleUpdater< T >::swap ( SimpleUpdater< T > &  other)

Swap this object with another.

Parameters
otherThe other object with which to swap.

This operation is NOT concurrency-safe. No other threads may be accessing either container during this operation.

◆ update()

template<class T >
void CxxUtils::SimpleUpdater< T >::update ( std::unique_ptr< T >  p,
const Context_t  
)

Install a new object.

Parameters
pThe new object to install.
ctxCurrent execution context.

The existing object should not be deleted until it can no longer be referenced by any thread.

Member Data Documentation

◆ m_obj

template<class T >
std::atomic<const T*> CxxUtils::SimpleUpdater< T >::m_obj = 0
private

Pointer to the current object.

Definition at line 116 of file SimpleUpdater.h.

◆ m_objs

template<class T >
std::vector<std::unique_ptr<T> > CxxUtils::SimpleUpdater< T >::m_objs
private

List of all allocated objects.

Definition at line 119 of file SimpleUpdater.h.


The documentation for this class was generated from the following file: