ATLAS Offline Software
Loading...
Searching...
No Matches
SegMemSvc.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "AthAllocators/ArenaCachingHandle.h"
6#include "AthAllocators/ArenaHandle.h"
7#include "AthAllocators/ArenaPoolAllocator.h"
8#include "StoreGate/tools/SGMsgStreamMacros.h"
9
10/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
11
12template <typename T>
13T*
14SegMemSvc::allocate(SegMemSvc::LIFETIME life, bool cache) {
15
16 T* ptr = 0;
17
18 if (cache) {
19 typedef SG::ArenaCachingHandle<T, SG::ArenaPoolAllocator> Handle_t;
20 if (life == SegMemSvc::EVENT) {
21 ptr = (T*)Handle_t(&m_ahead_evt).allocate();
22 } else if (life == SegMemSvc::JOB) {
23 ptr = (T*)Handle_t(&m_ahead_job).allocate();
24 } else if (life == SegMemSvc::INCIDENT) {
25 ptr = (T*)Handle_t(&m_ahead_inc).allocate();
26 }
27 } else {
28 typedef SG::ArenaHandle<T, SG::ArenaPoolAllocator> Handle_t;
29 if (life == SegMemSvc::EVENT) {
30 ptr = (T*)Handle_t(&m_ahead_evt).allocate();
31 } else if (life == SegMemSvc::JOB) {
32 ptr = (T*)Handle_t(&m_ahead_job).allocate();
33 } else if (life == SegMemSvc::INCIDENT) {
34 ptr = (T*)Handle_t(&m_ahead_inc).allocate();
35 }
36 }
37
38 if (msgStream().level() <= MSG::DEBUG) {
39 SG_MSG_DEBUG ("allocating object size {} with lifetime/cache {}/{} at {}",
40 sizeof(T), cvt(life), cache,
41 static_cast<void*>(ptr));
42 }
43
44
45 return ptr;
46
47}
48
49/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
50
51template <typename T>
52bool
53SegMemSvc::del(T* ptr) {
54
55 if (msgStream().level() <= MSG::DEBUG) {
56 SG_MSG_DEBUG ("deleting object at {}", static_cast<void*>(ptr));
57 }
58
59
60 return true;
61
62}