ATLAS Offline Software
Public Types | List of all members
SegMemSvc Class Reference

Service to access an arena caching allocator. More...

#include <SegMemSvc.h>

Inheritance diagram for SegMemSvc:
Collaboration diagram for SegMemSvc:

Public Types

enum  LIFETIME { EVENT = 0, JOB = 1, INCIDENT = 2 }
 

Internals: Gaudi boilerplate

virtual StatusCode initialize ()
 
virtual StatusCode reinitialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
virtual void handle (const Incident &)
 
static const InterfaceID & interfaceID ()
 

Client Interface: allocate and free memory

ServiceHandle< IIncidentSvc > p_incSvc
 
SG::ArenaHeader m_ahead_job
 three arenas for different lifetimes More...
 
SG::ArenaHeader m_ahead_evt
 
SG::ArenaHeader m_ahead_inc
 
SG::Arena m_arena_job
 
SG::Arena m_arena_evt
 
SG::Arena m_arena_inc
 
template<typename T >
T * allocate (SegMemSvc::LIFETIME, bool cache=true)
 Get pointer to an area in the arena, used for new with placement. More...
 
template<typename T >
bool del (T *)
 free memory managed by arena More...
 
 SegMemSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~SegMemSvc ()
 
std::string cvt (SegMemSvc::LIFETIME life)
 helper to for printout More...
 

Detailed Description

Service to access an arena caching allocator.

Parameters
Nouser settable jobOptions
Author
Charles Leggett
Id

Definition at line 29 of file SegMemSvc.h.

Member Enumeration Documentation

◆ LIFETIME

Enumerator
EVENT 
JOB 
INCIDENT 

Definition at line 35 of file SegMemSvc.h.

35  {
36  EVENT = 0,
37  JOB = 1,
38  INCIDENT = 2
39  };

Constructor & Destructor Documentation

◆ SegMemSvc()

SegMemSvc::SegMemSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 18 of file SegMemSvc.cxx.

19  : Service( name, svc ), p_incSvc("IncidentSvc",name),
20  m_arena_job("sms_job",&m_ahead_job),
21  m_arena_evt("sms_evt",&m_ahead_evt),
22  m_arena_inc("sms_inc",&m_ahead_inc)
23 {
24 
25 }

◆ ~SegMemSvc()

SegMemSvc::~SegMemSvc ( )
virtual

Definition at line 30 of file SegMemSvc.cxx.

30  {
31 
32 }

Member Function Documentation

◆ allocate()

template<typename T >
T* SegMemSvc::allocate ( SegMemSvc::LIFETIME  ,
bool  cache = true 
)

Get pointer to an area in the arena, used for new with placement.

Parameters
LIFETIMEobject lifetime in the arena: EVENT, JOB or INCIDENT
Returns
T* to be used with new with placement

◆ cvt()

std::string SegMemSvc::cvt ( SegMemSvc::LIFETIME  life)
inlineprivate

helper to for printout

Definition at line 89 of file SegMemSvc.h.

89  {
90  switch (life) {
91  case SegMemSvc::EVENT : return "EVENT";
92  case SegMemSvc::JOB : return "JOB";
93  case SegMemSvc::INCIDENT: return "INCIDENT";
94  }
95  return "UNKNOWN";
96  }

◆ del()

template<typename T >
bool SegMemSvc::del ( T *  )

free memory managed by arena

◆ finalize()

StatusCode SegMemSvc::finalize ( )
virtual

Definition at line 83 of file SegMemSvc.cxx.

83  {
84 
85  return StatusCode::SUCCESS;
86 
87 }

◆ handle()

void SegMemSvc::handle ( const Incident &  inc)
virtual

Definition at line 92 of file SegMemSvc.cxx.

92  {
93 
94  if (inc.type() == "EndEvent") {
95  if (msgStream().level() <= MSG::DEBUG) {
96  std::ostringstream ost;
98  debug() << "Running report for " << m_arena_evt.name()
99  << ost.str() << endmsg;
100  }
101 
102  debug() << "freeing all memory allocated for Event" << endmsg;
103  m_arena_evt.reset();
104  m_ahead_evt.reset();
105 
106  } else if ( inc.type() == "DefragMemory") {
107 
108  if (msgStream().level() <= MSG::DEBUG) {
109  debug() << "defragmenting memory" << endmsg;
110  }
111  debug() << "freeing all memory allocated associated with "
112  << "DefragMemory incident" << endmsg;
113  m_arena_inc.reset();
114  m_ahead_inc.reset();
115  }
116 
117 }

◆ initialize()

StatusCode SegMemSvc::initialize ( )
virtual

Definition at line 55 of file SegMemSvc.cxx.

55  {
56 
60 
61  // m_ahead.addArena(&m_arena);
62 
63 
64  p_incSvc->addListener( this, "EndEvent" );
65  p_incSvc->addListener( this, "DefragMemory" );
66 
67  return StatusCode::SUCCESS;
68 
69 }

◆ interfaceID()

static const InterfaceID& SegMemSvc::interfaceID ( )
inlinestatic

Definition at line 50 of file SegMemSvc.h.

50  {
51  static const InterfaceID IID("SegMemSvc", 1, 0);
52  return IID;
53  }

◆ queryInterface()

StatusCode SegMemSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 35 of file SegMemSvc.cxx.

36  {
37  StatusCode sc = StatusCode::FAILURE;
38  if ( ppvInterface ) {
39  *ppvInterface = 0;
40 
41  if ( SegMemSvc::interfaceID().versionMatch(riid) ) {
42  *ppvInterface = static_cast<SegMemSvc*>(this);
43  sc = StatusCode::SUCCESS;
44  addRef();
45  }
46  else
47  sc = Service::queryInterface( riid, ppvInterface );
48  }
49  return sc;
50 }

◆ reinitialize()

StatusCode SegMemSvc::reinitialize ( )
virtual

Definition at line 74 of file SegMemSvc.cxx.

74  {
75 
76  return StatusCode::SUCCESS;
77 
78 }

Member Data Documentation

◆ m_ahead_evt

SG::ArenaHeader SegMemSvc::m_ahead_evt
private

Definition at line 99 of file SegMemSvc.h.

◆ m_ahead_inc

SG::ArenaHeader SegMemSvc::m_ahead_inc
private

Definition at line 99 of file SegMemSvc.h.

◆ m_ahead_job

SG::ArenaHeader SegMemSvc::m_ahead_job
private

three arenas for different lifetimes

Definition at line 99 of file SegMemSvc.h.

◆ m_arena_evt

SG::Arena SegMemSvc::m_arena_evt
private

Definition at line 100 of file SegMemSvc.h.

◆ m_arena_inc

SG::Arena SegMemSvc::m_arena_inc
private

Definition at line 100 of file SegMemSvc.h.

◆ m_arena_job

SG::Arena SegMemSvc::m_arena_job
private

Definition at line 100 of file SegMemSvc.h.

◆ p_incSvc

ServiceHandle<IIncidentSvc> SegMemSvc::p_incSvc
private

Definition at line 86 of file SegMemSvc.h.


The documentation for this class was generated from the following files:
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
SegMemSvc::m_arena_inc
SG::Arena m_arena_inc
Definition: SegMemSvc.h:100
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SegMemSvc::JOB
@ JOB
Definition: SegMemSvc.h:37
SegMemSvc::m_ahead_inc
SG::ArenaHeader m_ahead_inc
Definition: SegMemSvc.h:99
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::ArenaHeader::report
void report(std::ostream &os) const
Generate a report of all Arenas in the group.
Definition: ArenaHeader.cxx:115
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ArenaBase::reset
void reset()
Reset all contained allocators.
Definition: ArenaBase.cxx:44
SegMemSvc::INCIDENT
@ INCIDENT
Definition: SegMemSvc.h:38
SG::ArenaHeader::reset
void reset()
Call reset on all Allocators in the current Arena.
Definition: ArenaHeader.cxx:153
SegMemSvc::m_ahead_evt
SG::ArenaHeader m_ahead_evt
Definition: SegMemSvc.h:99
SegMemSvc::m_arena_evt
SG::Arena m_arena_evt
Definition: SegMemSvc.h:100
SegMemSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: SegMemSvc.h:50
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
SegMemSvc
Service to access an arena caching allocator.
Definition: SegMemSvc.h:30
SegMemSvc::EVENT
@ EVENT
Definition: SegMemSvc.h:36
SegMemSvc::m_arena_job
SG::Arena m_arena_job
Definition: SegMemSvc.h:100
DEBUG
#define DEBUG
Definition: page_access.h:11
SegMemSvc::m_ahead_job
SG::ArenaHeader m_ahead_job
three arenas for different lifetimes
Definition: SegMemSvc.h:99
SegMemSvc::p_incSvc
ServiceHandle< IIncidentSvc > p_incSvc
Definition: SegMemSvc.h:86
SG::ArenaBase::name
const std::string & name() const
Return this Arena's name.
Definition: ArenaBase.cxx:114
SG::Arena::Push
Helper class for making Arena instances current in a stack-like manner.
Definition: Arena.h:273