ATLAS Offline Software
SegMemSvc.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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 
9 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10 
11 template <typename T>
12 T*
13 SegMemSvc::allocate(SegMemSvc::LIFETIME life, bool cache) {
14 
15  T* ptr = 0;
16 
17  if (cache) {
18  typedef SG::ArenaCachingHandle<T, SG::ArenaPoolAllocator> Handle_t;
19  if (life == SegMemSvc::EVENT) {
20  ptr = (T*)Handle_t(&m_ahead_evt).allocate();
21  } else if (life == SegMemSvc::JOB) {
22  ptr = (T*)Handle_t(&m_ahead_job).allocate();
23  } else if (life == SegMemSvc::INCIDENT) {
24  ptr = (T*)Handle_t(&m_ahead_inc).allocate();
25  }
26  } else {
27  typedef SG::ArenaHandle<T, SG::ArenaPoolAllocator> Handle_t;
28  if (life == SegMemSvc::EVENT) {
29  ptr = (T*)Handle_t(&m_ahead_evt).allocate();
30  } else if (life == SegMemSvc::JOB) {
31  ptr = (T*)Handle_t(&m_ahead_job).allocate();
32  } else if (life == SegMemSvc::INCIDENT) {
33  ptr = (T*)Handle_t(&m_ahead_inc).allocate();
34  }
35  }
36 
37  if (msgStream().level() <= MSG::DEBUG) {
38  debug() << "allocating object size " << sizeof(T)
39  << " with lifetime/cache " << cvt(life) << "/" << cache << " at "
40  << ptr << endmsg;
41  }
42 
43 
44  return ptr;
45 
46 }
47 
48 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49 
50 template <typename T>
51 bool
52 SegMemSvc::del(T* ptr) {
53 
54  if (msgStream().level() <= MSG::DEBUG) {
55  debug() << "deleting object at " << ptr << endmsg;
56  }
57 
58 
59  return true;
60 
61 }