ATLAS Offline Software
Loading...
Searching...
No Matches
PhaseII::IndexedRangesMT< T_RawDataContainer > Class Template Reference

Extended Helper class to associate ranges of elements in multiple containers to a contiguous index to be used in a MT context The base class is extended by a container list which can be grown dynamically (mutex protected), and the per module element range is atomic. More...

#include <PhaseIIInDetRawDataContainerMT.h>

Inheritance diagram for PhaseII::IndexedRangesMT< T_RawDataContainer >:
Collaboration diagram for PhaseII::IndexedRangesMT< T_RawDataContainer >:

Public Types

typedef std::true_type thread_safe
using BASE = PhaseII::IndexedRanges<T_RawDataContainer, std::atomic<PhaseII::DataRange> >
using ContainerPtr = typename DynamicContainerListHelper<T_RawDataContainer>::ContainerPtr
using DataContainerType
using T_RangeTypeBase

Public Member Functions

 IndexedRangesMT (unsigned int n_ranges, unsigned int n_slots)
ContainerPtr getNewContainerPtr ()
 get an unused container to add new RDOs.
unsigned int getNewContainerIndex ()
 Add a new container to the list of containers and return its index.
bool registerOrEraseNewData (unsigned int index, const T_RangeTypeBase &new_range)
 register an element range or erase the elements of this range.
bool update (unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)
 update a range (version for an "atomic" range)
bool update (unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)
 update a range (version for a "non-atomic" range)
const T_RawDataContainer & data (unsigned int container_index) const
 Get an existing container from the container collection (read only).
T_RawDataContainer & data (unsigned int container_index)
 Get an existing container from the container collection.
const std::atomic< PhaseII::DataRange > & range (unsigned int index) const
 Get a specific element range.
std::size_t size () const
 return the total number of element ranges.
std::size_t empty () const
 return true there are no element ranges.
std::size_t containerListCapacity () const
const auto & errorContainer (unsigned int container_index) const
 if there is an associated error container get it.
auto & errorContainer (unsigned int container_index)
 if there is an associated error container get it (read/write access).

Protected Attributes

ContainerList< T_RawDataContainer > m_containers
std::vector< std::atomic< PhaseII::DataRange > > m_range

Private Attributes

DynamicContainerListHelper< T_RawDataContainer > m_containerListHelper

Detailed Description

template<class T_RawDataContainer>
class PhaseII::IndexedRangesMT< T_RawDataContainer >

Extended Helper class to associate ranges of elements in multiple containers to a contiguous index to be used in a MT context The base class is extended by a container list which can be grown dynamically (mutex protected), and the per module element range is atomic.

If the initial guess for the container list is conservative enough, then the only additional overhead are atomic operations when registering an element range per module, the atomic operation to the increment the container used counter. If the initial guess was too optimistic, the container list needs to be grown which is mutex protected, but will be done in chunks.

Definition at line 20 of file PhaseIIInDetRawDataContainerMT.h.

Member Typedef Documentation

◆ BASE

template<class T_RawDataContainer>
using PhaseII::IndexedRangesMT< T_RawDataContainer >::BASE = PhaseII::IndexedRanges<T_RawDataContainer, std::atomic<PhaseII::DataRange> >

Definition at line 24 of file PhaseIIInDetRawDataContainerMT.h.

◆ ContainerPtr

template<class T_RawDataContainer>
using PhaseII::IndexedRangesMT< T_RawDataContainer >::ContainerPtr = typename DynamicContainerListHelper<T_RawDataContainer>::ContainerPtr

Definition at line 26 of file PhaseIIInDetRawDataContainerMT.h.

◆ DataContainerType

using PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::DataContainerType
inherited

Definition at line 82 of file PhaseIIInDetRawDataContainer.h.

◆ T_RangeTypeBase

using PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::T_RangeTypeBase
inherited

Definition at line 83 of file PhaseIIInDetRawDataContainer.h.

◆ thread_safe

template<class T_RawDataContainer>
typedef std::true_type PhaseII::IndexedRangesMT< T_RawDataContainer >::thread_safe

Definition at line 23 of file PhaseIIInDetRawDataContainerMT.h.

Constructor & Destructor Documentation

◆ IndexedRangesMT()

template<class T_RawDataContainer>
PhaseII::IndexedRangesMT< T_RawDataContainer >::IndexedRangesMT ( unsigned int n_ranges,
unsigned int n_slots )
inline

Definition at line 27 of file PhaseIIInDetRawDataContainerMT.h.

Extended Helper class to associate ranges of elements in multiple containers to a contiguous index to...
PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > > BASE

Member Function Documentation

◆ containerListCapacity()

std::size_t PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::containerListCapacity ( ) const
inlineinherited

Definition at line 154 of file PhaseIIInDetRawDataContainer.h.

154{ return m_containers.size(); }
Helper class to associate ranges of elements in multiple containers to a contiguous index.
std::size_t size() const
return the total number of element ranges.

◆ data() [1/2]

T_RawDataContainer & PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::data ( unsigned int container_index)
inlineinherited

Get an existing container from the container collection.

Parameters
container_indexthe index which identifies the container in the container collection.

Definition at line 136 of file PhaseIIInDetRawDataContainer.h.

◆ data() [2/2]

const T_RawDataContainer & PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::data ( unsigned int container_index) const
inlineinherited

Get an existing container from the container collection (read only).

Parameters
container_indexthe index which identifies the container in the container collection.

Definition at line 131 of file PhaseIIInDetRawDataContainer.h.

◆ empty()

std::size_t PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::empty ( ) const
inlineinherited

return true there are no element ranges.

Definition at line 151 of file PhaseIIInDetRawDataContainer.h.

151{ return m_range.empty(); }
std::size_t empty() const
return true there are no element ranges.

◆ errorContainer() [1/2]

auto & PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::errorContainer ( unsigned int container_index)
inlineinherited

if there is an associated error container get it (read/write access).

Definition at line 163 of file PhaseIIInDetRawDataContainer.h.

163 {
165 return m_containers[container_index].errors();
166 }

◆ errorContainer() [2/2]

const auto & PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::errorContainer ( unsigned int container_index) const
inlineinherited

if there is an associated error container get it.

Definition at line 157 of file PhaseIIInDetRawDataContainer.h.

◆ getNewContainerIndex()

template<class T_RawDataContainer>
unsigned int PhaseII::IndexedRangesMT< T_RawDataContainer >::getNewContainerIndex ( )
inline

Add a new container to the list of containers and return its index.

if the container list capacity is not exhausted a new container list will be created with a larger capacity and the contents of the current list will be copied to it. All future requests will use that new list, but the old list is kept arround since there may still be users, and there is no reference counting.

Definition at line 43 of file PhaseIIInDetRawDataContainerMT.h.

43 {
45 unsigned int container_index = container_ptr.containerId();
47 }
ContainerPtr getNewContainerPtr()
get an unused container to add new RDOs.
typename DynamicContainerListHelper< T_RawDataContainer >::ContainerPtr ContainerPtr

◆ getNewContainerPtr()

template<class T_RawDataContainer>
ContainerPtr PhaseII::IndexedRangesMT< T_RawDataContainer >::getNewContainerPtr ( )
inline

get an unused container to add new RDOs.

Returns
will return an used preallocated container or grow the container list and return a newly allocated container. If the container list is not yet exhausted this only requires an atomic operation, otherwise new storage will need to be allocated which is mutex protected.

Definition at line 34 of file PhaseIIInDetRawDataContainerMT.h.

34 {
35 return m_containerListHelper.getNewContainer(this->m_containers);
36 }
DynamicContainerListHelper< T_RawDataContainer > m_containerListHelper

◆ range()

const std::atomic< PhaseII::DataRange > & PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::range ( unsigned int index) const
inlineinherited

Get a specific element range.

Parameters
indexthe index which identifies the element range the element range will in addition to the actual element range also provide the index of the container in container collection which contains these elements.

Definition at line 143 of file PhaseIIInDetRawDataContainer.h.

143 {
145 return m_range[index];
146 }

◆ registerOrEraseNewData()

bool PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::registerOrEraseNewData ( unsigned int index,
const T_RangeTypeBase & new_range )
inlineinherited

register an element range or erase the elements of this range.

Parameters
indexand index which identifies the range i.e. the group of elements of this range
new_rangethe element range that should be be registered. The element range will be registered for the given index unless a range has been registered already. In the latter case the element of this new range well be erased.

Definition at line 97 of file PhaseIIInDetRawDataContainer.h.

98 {
100 assert( new_range.containerIndex() < m_containers.size() );
102 if (is_range.size() != new_range.size()) {
105 return true;
106 }
107 }
108 // it is assumed that data is always added at the end and then registered.
109 assert( new_range.beginIndex() + new_range.size() == m_containers[new_range.containerIndex()].size());
110 m_containers[new_range.containerIndex()].erase_back(new_range.beginIndex());
111 return false;
112 }
bool update(unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)

◆ size()

std::size_t PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::size ( ) const
inlineinherited

return the total number of element ranges.

Definition at line 149 of file PhaseIIInDetRawDataContainer.h.

149{ return m_range.size(); }

◆ update() [1/2]

bool PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::update ( unsigned int index,
T_RangeTypeBase & is_range,
const T_RangeTypeBase & new_range )
inlineinherited

update a range (version for an "atomic" range)

Definition at line 115 of file PhaseIIInDetRawDataContainer.h.

116 {
117 assert( index < m_range.size());
118 return m_range[index].compare_exchange_weak(is_range, new_range);
119 }

◆ update() [2/2]

bool PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::update ( unsigned int index,
T_RangeTypeBase & is_range,
const T_RangeTypeBase & new_range )
inlineinherited

update a range (version for a "non-atomic" range)

Definition at line 122 of file PhaseIIInDetRawDataContainer.h.

123 {
124 assert( index < m_range.size());
126 return true;
127 }

Member Data Documentation

◆ m_containerListHelper

template<class T_RawDataContainer>
DynamicContainerListHelper<T_RawDataContainer> PhaseII::IndexedRangesMT< T_RawDataContainer >::m_containerListHelper
private

Definition at line 50 of file PhaseIIInDetRawDataContainerMT.h.

◆ m_containers

ContainerList<T_RawDataContainer> PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::m_containers
protectedinherited

Definition at line 169 of file PhaseIIInDetRawDataContainer.h.

◆ m_range

std::vector<std::atomic< PhaseII::DataRange >> PhaseII::IndexedRanges< T_RawDataContainer, std::atomic< PhaseII::DataRange > >::m_range
protectedinherited

Definition at line 170 of file PhaseIIInDetRawDataContainer.h.


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