ATLAS Offline Software
AtomicDecorator.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
25 #ifndef ATHCONTAINERS_ATOMICDECORATOR_H
26 #define ATHCONTAINERS_ATOMICDECORATOR_H
27 
28 
31 #include <atomic>
32 #include <type_traits>
33 
34 
35 namespace SG {
36 
37 
41 template <class T, class ALLOC = AuxAllocator_t<T> >
43  : public Decorator<T, ALLOC>
44 {
45 public:
48 
50  using reference_type = std::atomic<T>&;
51 
54 
56  using container_pointer_type = std::atomic<T>*;
57  using const_container_pointer_type = const std::atomic<T>*;
58 
59  // Consistency checks.
61  "Bad type for AtomicDecorator");
63  "Bad type for AtomicDecorator");
64 
66  "Bad type for AtomicDecorator");
68  "Bad type for AtomicDecorator");
69  static_assert (sizeof(T) == sizeof(std::atomic<T>),
70  "Bad type for AtomicDecorator");
71  static_assert (std::atomic<T>::is_always_lock_free,
72  "Bad type for AtomicDecorator");
73 
74 
81  AtomicDecorator (const std::string& name);
82 
83 
91  AtomicDecorator (const std::string& name, const std::string& clsname);
92 
93 
101 
102 
111  template <class ELT>
112  ATH_REQUIRES( IsConstAuxElement<ELT> )
113  reference_type operator() (const ELT& e) const;
114 
115 
130  operator() (const AuxVectorData& container, size_t index) const;
131 
132 
139 
140 
146 
147 
157 };
158 
159 
160 } // namespace SG
161 
162 
163 #include "AthContainers/tools/AtomicDecorator.icc"
164 
165 
166 #endif // not ATHCONTAINERS_ATOMICDECORATOR_H
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
index
Definition: index.py:1
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:446
athena.value
value
Definition: athena.py:122
ATH_REQUIRES
#define ATH_REQUIRES(...)
Definition: concepts.h:104
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::AtomicDecorator::AtomicDecorator
AtomicDecorator(const std::string &name)
Constructor.
SG::Decorator< T, AuxAllocator_t< T > >::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
x
#define x
SG::AtomicDecorator::getDataArray
const_container_pointer_type getDataArray(const AuxVectorData &container) const
Get a pointer to the start of the auxiliary data array.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
AuxDataTraits.h
Allow customizing how aux data types are treated.
SG::AtomicDecorator::getDecorationArray
container_pointer_type getDecorationArray(const AuxVectorData &container) const
Get a pointer to the start of the auxiliary data array.
SG::AuxDataTraits::element_type
T element_type
The type the user sees.
Definition: AuxDataTraits.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::AtomicDecorator::AtomicDecorator
AtomicDecorator(const SG::auxid_t auxid)
Constructor taking an auxid directly.
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
SG::AtomicDecorator::const_container_pointer_type
const std::atomic< T > * const_container_pointer_type
Definition: AtomicDecorator.h:57
SG::AtomicDecorator::reference_type
std::atomic< T > & reference_type
Type referencing an item.
Definition: AtomicDecorator.h:50
SG::AtomicDecorator::set
void set(const AuxElement &e, const element_type &x) const
Set the variable for one element.
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:167
SG::AtomicDecorator
Access an auxiliary variable atomically.
Definition: AtomicDecorator.h:44
SG::AtomicDecorator::AtomicDecorator
AtomicDecorator(const std::string &name, const std::string &clsname)
Constructor.
SG::AtomicDecorator::element_type
typename AuxDataTraits< T, ALLOC >::element_type element_type
Type the user sees.
Definition: AtomicDecorator.h:53
SG::AtomicDecorator::container_pointer_type
std::atomic< T > * container_pointer_type
Pointer into the container holding this item.
Definition: AtomicDecorator.h:56
AuxElement.h
Base class for elements of a container that can have aux data.