ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthDevice
AthDeviceComps
src
MonitoredMemoryResource.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).
6
#include "
MonitoredMemoryResource.h
"
7
8
namespace
AthDevice
{
9
10
MonitoredMemoryResource::MonitoredMemoryResource
(
11
std::pmr::memory_resource& upstream,
IMemoryMonitorSvc
& svc,
12
const
std::string& component,
const
std::string& device)
13
:
m_upstream
(upstream),
14
m_svc
(svc),
15
m_component
(component),
16
m_device
(device) {}
17
18
MonitoredMemoryResource::~MonitoredMemoryResource
() =
default
;
19
20
void
*
MonitoredMemoryResource::do_allocate
(std::size_t bytes,
21
std::size_t alignment) {
22
23
// Forward the allocation to the upstream memory resource.
24
void
* result =
m_upstream
.get().allocate(bytes, alignment);
25
26
// Notify the service that a memory allocation has been made.
27
m_svc
.get().memoryAllocated(
m_component
,
m_device
, bytes);
28
29
// Return the pointer to the allocated memory.
30
return
result;
31
}
32
33
void
MonitoredMemoryResource::do_deallocate
(
void
* p, std::size_t bytes,
34
std::size_t alignment) {
35
36
// Forward the deallocation to the upstream memory resource.
37
m_upstream
.get().deallocate(p, bytes, alignment);
38
39
// Notify the service that a memory deallocation has been made.
40
m_svc
.get().memoryDeallocated(
m_component
,
m_device
, bytes);
41
}
42
43
bool
MonitoredMemoryResource::do_is_equal
(
44
const
std::pmr::memory_resource& other)
const
noexcept
{
45
46
// Simple "object identity" check.
47
return
this
== &other;
48
}
49
50
}
// namespace AthDevice
MonitoredMemoryResource.h
AthDevice::IMemoryMonitorSvc
Interface to a service that provides "device memory monitoring".
Definition
IMemoryMonitorSvc.h:20
AthDevice::MonitoredMemoryResource::~MonitoredMemoryResource
virtual ~MonitoredMemoryResource()
Destructor.
AthDevice::MonitoredMemoryResource::do_allocate
virtual void * do_allocate(std::size_t bytes, std::size_t alignment) override
Allocate memory from the resource.
Definition
MonitoredMemoryResource.cxx:20
AthDevice::MonitoredMemoryResource::m_upstream
std::reference_wrapper< std::pmr::memory_resource > m_upstream
The upstream memory resource to which the allocations are forwarded.
Definition
MonitoredMemoryResource.h:53
AthDevice::MonitoredMemoryResource::m_device
std::string m_device
The name of the device for which the memory resource is provided.
Definition
MonitoredMemoryResource.h:59
AthDevice::MonitoredMemoryResource::do_is_equal
virtual bool do_is_equal(const std::pmr::memory_resource &other) const noexcept override
Check if the resource is equal to another resource.
Definition
MonitoredMemoryResource.cxx:43
AthDevice::MonitoredMemoryResource::m_svc
std::reference_wrapper< IMemoryMonitorSvc > m_svc
The service used to monitor the memory allocations/deallocations.
Definition
MonitoredMemoryResource.h:55
AthDevice::MonitoredMemoryResource::m_component
std::string m_component
The name of the component that is using this memory resource.
Definition
MonitoredMemoryResource.h:57
AthDevice::MonitoredMemoryResource::do_deallocate
virtual void do_deallocate(void *p, std::size_t bytes, std::size_t alignment) override
Deallocate memory from the resource.
Definition
MonitoredMemoryResource.cxx:33
AthDevice::MonitoredMemoryResource::MonitoredMemoryResource
MonitoredMemoryResource(std::pmr::memory_resource &upstream, IMemoryMonitorSvc &svc, const std::string &component, const std::string &device)
Constructor.
Definition
MonitoredMemoryResource.cxx:10
AthDevice
Definition
BinaryPageMemoryResourceSvc.cxx:15
Generated on
for ATLAS Offline Software by
1.17.0