ATLAS Offline Software
Loading...
Searching...
No Matches
MonitoredMemoryResourceTool.cxx
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3//
4
5// Local include(s).
7
9
10namespace AthDevice {
11
13
14 // Retrieve the upstream tool.
15 ATH_CHECK(m_mrTool.retrieve());
16
17 // Retrieve the monitoring service.
18 ATH_CHECK(m_monitorSvc.retrieve());
19
20 // Get the name of the tool's parent.
21 std::string component;
22 const INamedInterface* parent =
23 dynamic_cast<const INamedInterface*>(this->parent());
24 if (parent) {
25 component = parent->name();
26 } else {
27 ATH_MSG_WARNING("Could not retrieve the name of the parent component");
28 component = "Unknown";
29 }
30
31 // Construct the monitored resource.
32 m_mr = std::make_unique<MonitoredMemoryResource>(
33 m_mrTool->mr(), *m_monitorSvc, component, std::string{deviceName()});
34
35 // Return gracefully.
36 return StatusCode::SUCCESS;
37}
38
39std::pmr::memory_resource& MonitoredMemoryResourceTool::mr() const {
40
41 assert(m_mr);
42 return *m_mr;
43}
44
46
47 assert(m_mrTool.isValid());
48 return m_mrTool->deviceName();
49}
50
51} // namespace AthDevice
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x,...)
ServiceHandle< IMemoryMonitorSvc > m_monitorSvc
Service collecting the memory monitoring information.
virtual StatusCode initialize() override
Initialize the tool.
std::unique_ptr< std::pmr::memory_resource > m_mr
The memory resource that this tool uses.
ToolHandle< IMemoryResourceTool > m_mrTool
Underlying memory resource to use for allocations.
virtual std::pmr::memory_resource & mr() const override
Get the provided std::pmr::memory_resource object.
virtual std::string_view deviceName() const override
The name of the device for which the memory resource is provided.