ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODCore
Root
IOStats.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Local include(s):
6
#include "
xAODCore/tools/IOStats.h
"
7
#include "
CxxUtils/checker_macros.h
"
8
9
namespace
xAOD
{
10
11
IOStats
&
IOStats::instance
() {
12
13
static
IOStats
obj
ATLAS_THREAD_SAFE
;
14
return
obj;
15
}
16
17
ReadStats
&
IOStats::stats
() {
18
19
// Try to access a cached pointer:
20
ReadStats
*
stats
=
m_ptr
.get();
21
22
// If a pointer is not cached yet, do so now:
23
if
( !
stats
) {
24
const
std::thread::id
id
= std::this_thread::get_id();
25
std::lock_guard< std::mutex >
lock
(
m_mutex
);
26
stats
= &(
m_stats
[ id ] );
27
m_ptr
.reset(
stats
);
28
}
29
30
// Return the (now) cached object:
31
return
*
stats
;
32
}
33
34
ReadStats
IOStats::merged
()
const
{
35
36
// Get a lock on the map:
37
std::lock_guard< std::mutex >
lock
(
m_mutex
);
38
39
// Merge the objects from all the threads:
40
ReadStats
result;
41
for
(
const
auto
&
pair
:
m_stats
) {
42
result +=
pair
.second;
43
}
44
45
// Return the merged object:
46
return
result;
47
}
48
49
IOStats::IOStats
()
50
:
m_stats
(),
51
// Make sure that the thread specific pointer doesn't try to delete
52
// the object it points to when the thread ends:
53
m_ptr
( [](
ReadStats
* ){} ),
54
m_mutex() {
55
56
}
57
58
}
// namespace xAOD
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
IOStats.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
pair
STL class.
xAOD::IOStats::m_stats
std::map< std::thread::id, ReadStats > m_stats
Objects describing the file access pattern, per thread.
Definition
IOStats.h:73
xAOD::IOStats::stats
ReadStats & stats()
Access the object belonging to the current thread.
Definition
IOStats.cxx:17
xAOD::IOStats::m_ptr
AthContainers_detail::thread_specific_ptr< ReadStats > m_ptr
Thread specific pointer to the ReadStats object of the current thread.
Definition
IOStats.h:76
xAOD::IOStats::merged
ReadStats merged() const
Access the statistics object, merging information from all threads.
Definition
IOStats.cxx:34
xAOD::IOStats::IOStats
IOStats()
The constructor of the object is made private.
Definition
IOStats.cxx:49
xAOD::IOStats::m_mutex
std::mutex m_mutex
Mutex for accessing the read statistics.
Definition
IOStats.h:79
xAOD::IOStats::instance
static IOStats & instance()
Singleton object accessor.
Definition
IOStats.cxx:11
xAOD::ReadStats
Class describing the access statistics of a collection of branches.
Definition
ReadStats.h:123
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
Generated on
for ATLAS Offline Software by
1.17.0