ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
CxxUtils
SimpleUpdater.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-2023 CERN for the benefit of the ATLAS collaboration.
4
*/
11
12
13
#ifndef CXXUTILS_SIMPLEUPDATER_H
14
#define CXXUTILS_SIMPLEUPDATER_H
15
16
17
#include <atomic>
18
#include <vector>
19
#include <memory>
20
#include <algorithm>
21
22
23
namespace
CxxUtils
{
24
25
35
template
<
class
T>
36
class
SimpleUpdater
37
{
38
public
:
41
struct
Context_t
{};
42
44
SimpleUpdater
() =
default
;
45
46
50
SimpleUpdater
(
SimpleUpdater
&& other);
51
52
56
const
T&
get
()
const
;
57
58
67
void
update
(std::unique_ptr<T> p,
const
Context_t
&);
68
69
78
void
discard
(std::unique_ptr<T> p);
79
80
86
void
quiescent
(
const
Context_t
&);
87
88
95
void
clean
();
96
97
105
void
swap
(
SimpleUpdater
& other);
106
107
111
static
const
Context_t
defaultContext
();
112
113
114
private
:
116
std::atomic<const T*>
m_obj
= 0;
117
119
std::vector<std::unique_ptr<T> >
m_objs
;
120
};
121
122
123
}
// namespace CxxUtils
124
125
126
#include "
CxxUtils/SimpleUpdater.icc
"
127
128
129
#endif
// not CXXUTILS_SIMPLEUPDATER_H
SimpleUpdater.icc
CxxUtils::SimpleUpdater::clean
void clean()
Delete all objects we're managing except for the current one.
CxxUtils::SimpleUpdater::m_objs
std::vector< std::unique_ptr< T > > m_objs
List of all allocated objects.
Definition
SimpleUpdater.h:119
CxxUtils::SimpleUpdater::update
void update(std::unique_ptr< T > p, const Context_t &)
Install a new object.
CxxUtils::SimpleUpdater::swap
void swap(SimpleUpdater &other)
Swap this object with another.
CxxUtils::SimpleUpdater::quiescent
void quiescent(const Context_t &)
Mark that an event slot is not referencing this object.
CxxUtils::SimpleUpdater::get
const T & get() const
Return a reference to the current object.
CxxUtils::SimpleUpdater::SimpleUpdater
SimpleUpdater(SimpleUpdater &&other)
Move constructor.
CxxUtils::SimpleUpdater::defaultContext
static const Context_t defaultContext()
Return the current event context.
CxxUtils::SimpleUpdater::SimpleUpdater
SimpleUpdater()=default
We need a default constructor.
CxxUtils::SimpleUpdater::m_obj
std::atomic< const T * > m_obj
Pointer to the current object.
Definition
SimpleUpdater.h:116
CxxUtils::SimpleUpdater::discard
void discard(std::unique_ptr< T > p)
Queue an object for later deletion.
CxxUtils
Definition
aligned_vector.h:29
CxxUtils::SimpleUpdater::Context_t
Context object.
Definition
SimpleUpdater.h:41
Generated on
for ATLAS Offline Software by
1.17.0