ATLAS Offline Software
Loading...
Searching...
No Matches
DynamicContainerListHelper< T_Container > Struct Template Reference

Helper class which allows to dynamically grow the container list. More...

#include <ContainerList.h>

Collaboration diagram for DynamicContainerListHelper< T_Container >:

Classes

struct  ContainerPtr
 Helper which provides a pointer to a container and the index of the container in the container list. More...

Public Types

using T_ContainerPtr = T_Container *

Public Member Functions

void addLargerContainerList (unsigned int container_idx, ContainerList< T_Container > &container_list)
 If the specified entry does not exist in the container list create an extended copy which contains this entry.
ContainerPtr getNewContainer (ContainerList< T_Container > &container_list)
 Get an unused container from the given container list.

Public Attributes

std::mutex m_containerListMutex
std::atomic< unsigned int > m_used {}

Detailed Description

template<typename T_Container>
struct DynamicContainerListHelper< T_Container >

Helper class which allows to dynamically grow the container list.

Definition at line 88 of file ContainerList.h.

Member Typedef Documentation

◆ T_ContainerPtr

template<typename T_Container>
using DynamicContainerListHelper< T_Container >::T_ContainerPtr = T_Container *

Definition at line 89 of file ContainerList.h.

Member Function Documentation

◆ addLargerContainerList()

template<typename T_Container>
void DynamicContainerListHelper< T_Container >::addLargerContainerList ( unsigned int container_idx,
ContainerList< T_Container > & container_list )
inline

If the specified entry does not exist in the container list create an extended copy which contains this entry.

Parameters
container_idxThe index which specifies the container in the container list
container_listthe container list. If container_idx specifies a container beyond this list, the current list is copied and extended to contain the specified container. The operation is mutex protected.

Definition at line 123 of file ContainerList.h.

123 {
125 if (container_idx >= container_list.m_containerList.size()) {
126 // create new container list with min_elements extra elements i.e. grow in chunks
127 static constexpr std::size_t min_elments = (sizeof(T_ContainerPtr)>=32u ? 1ul : 64ul/sizeof(T_ContainerPtr)-1);
129 unsigned int n=new_size - container_list.m_containerList.size();
130 // add a new container_list and add new empty containers
131 container_list.m_container.emplace_back( n );
132 container_list.m_containerListHistory.emplace_back( new_size );
133 std::vector<T_ContainerPtr> &new_container_list = container_list.m_containerListHistory.back();
135 assert(new_container_list.size()>=container_list.m_containerList.size());
136 // copy pointers from original container list to new container list
137 std::copy(container_list.m_containerList.begin(),container_list.m_containerList.end(),new_container_list.begin());
138 // set pointers of new container_list
139 container_list.m_containerList = ContainerList<T_Container>::fillContainerList(container_list.m_containerList.size(),
142 }
143 }
static std::span< T_ContainerPtr > fillContainerList(unsigned int begin_idx, std::vector< T_Container > &container, std::span< T_ContainerPtr > container_list)
Write pointers to containers in the given vector to a list starting at begin_index.
Helper class which allows to dynamically grow the container list.
std::atomic< unsigned int > m_used

◆ getNewContainer()

template<typename T_Container>
ContainerPtr DynamicContainerListHelper< T_Container >::getNewContainer ( ContainerList< T_Container > & container_list)
inline

Get an unused container from the given container list.

If the preallocated list of containers is exceeded. The container list will be extended.

Definition at line 147 of file ContainerList.h.

147 {
148 unsigned int container_idx = m_used++;
149 if (container_idx >= container_list.m_containerList.size()) {
151 }
153 }
Helper which provides a pointer to a container and the index of the container in the container list.
void addLargerContainerList(unsigned int container_idx, ContainerList< T_Container > &container_list)
If the specified entry does not exist in the container list create an extended copy which contains th...

Member Data Documentation

◆ m_containerListMutex

template<typename T_Container>
std::mutex DynamicContainerListHelper< T_Container >::m_containerListMutex

Definition at line 155 of file ContainerList.h.

◆ m_used

template<typename T_Container>
std::atomic<unsigned int> DynamicContainerListHelper< T_Container >::m_used {}

Definition at line 156 of file ContainerList.h.

156{};

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