ATLAS Offline Software
Loading...
Searching...
No Matches
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-2025 CERN for the benefit of the ATLAS collaboration
4*/
23
24
25#ifndef ATHCONTAINERS_ATOMICDECORATOR_H
26#define ATHCONTAINERS_ATOMICDECORATOR_H
27
28
31#include <atomic>
32#include <type_traits>
33
34
35namespace SG {
36
37
41template <class T, class ALLOC = AuxAllocator_t<T> >
43 : public Decorator<T, ALLOC>
44{
45public:
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.
60 static_assert (std::is_same<T, typename Base::element_type>::value,
61 "Bad type for AtomicDecorator");
62 static_assert (std::is_same<T&, typename Base::reference_type>::value,
63 "Bad type for AtomicDecorator");
64
65 static_assert (std::is_same<T*, typename Base::container_pointer_type>::value,
66 "Bad type for AtomicDecorator");
67 static_assert (std::is_same<const T*, typename Base::const_container_pointer_type>::value,
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 <IsConstAuxElement ELT>
112 reference_type operator() (const ELT& e) const;
113
114
130
131
137 void set (const AuxElement& e, const element_type& x) const;
138
139
145
146
156};
157
158
159} // namespace SG
160
161
163
164
165#endif // not ATHCONTAINERS_ATOMICDECORATOR_H
Allow customizing how aux data types are treated.
Base class for elements of a container that can have aux data.
#define x
std::atomic< T > & reference_type
Type referencing an item.
container_pointer_type getDecorationArray(const AuxVectorData &container) const
Get a pointer to the start of the auxiliary data array.
void set(const AuxElement &e, const element_type &x) const
Set the variable for one element.
const std::atomic< T > * const_container_pointer_type
AtomicDecorator(const std::string &name)
Constructor.
const_container_pointer_type getDataArray(const AuxVectorData &container) const
Get a pointer to the start of the auxiliary data array.
AtomicDecorator(const SG::auxid_t auxid)
Constructor taking an auxid directly.
std::atomic< T > * container_pointer_type
Pointer into the container holding this item.
reference_type operator()(const ELT &e) const
Fetch the variable for one element, as a non-const reference.
typename AuxDataTraits< T, ALLOC >::element_type element_type
Type the user sees.
Decorator< T, ALLOC > Base
Base class.
AtomicDecorator(const std::string &name, const std::string &clsname)
Constructor.
T element_type
The type the user sees.
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
Manage lookup of vectors of auxiliary data.
Decorator(const std::string &name)
Constructor.
SG::auxid_t auxid() const
Return the aux id for this variable.
Forward declaration.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Definition index.py:1