ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthXRT
AthXRTInterfaces
AthXRTInterfaces
StateHandler.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
//
4
// Dear emacs, this is -*- c++ -*-
5
//
6
7
#ifndef ATHXRTINTERFACES_STATEHANDLER_H
8
#define ATHXRTINTERFACES_STATEHANDLER_H
9
10
#include "GaudiKernel/IIncidentListener.h"
11
#include "GaudiKernel/IIncidentSvc.h"
12
#include "GaudiKernel/ConcurrencyFlags.h"
13
#include "GaudiKernel/ServiceHandle.h"
14
15
#include "
AthenaBaseComps/AthCheckMacros.h
"
16
#include "
AthenaInterprocess/Incidents.h
"
17
18
19
namespace
AthXRT
{
25
26
class
StateHandler
:
virtual
public
::IIncidentListener
27
{
28
protected
:
29
31
virtual
StatusCode
initialize_global
()
32
{
33
return
StatusCode::SUCCESS;
34
}
35
37
virtual
StatusCode
initialize_worker
()
38
{
39
return
StatusCode::SUCCESS;
40
}
41
43
virtual
StatusCode
stop_worker
()
44
{
45
return
StatusCode::SUCCESS;
46
}
47
48
virtual
StatusCode
initialize
()
49
{
50
ATH_CHECK
(this->
initialize_global
());
51
52
const
bool
is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
53
54
if
(is_multiprocess)
55
{
56
ServiceHandle<IIncidentSvc>
incidentSvc(
"IncidentSvc"
,
"StateHandler"
);
57
incidentSvc->addListener(
this
,
AthenaInterprocess::UpdateAfterFork::type
());
58
}
59
else
60
{
61
ATH_CHECK
(this->
initialize_worker
());
62
}
63
64
return
StatusCode::SUCCESS;
65
}
66
67
virtual
StatusCode
stop
() {
68
const
bool
is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
69
70
if
(!is_multiprocess) {
71
ATH_CHECK
(this->
stop_worker
());
72
}
else
{
73
if
(
m_is_child
){
74
ATH_CHECK
(this->
stop_worker
());
75
}
76
}
77
78
return
StatusCode::SUCCESS;
79
}
80
81
bool
m_is_child
=
false
;
82
83
public
:
84
85
void
handle
(
const
Incident & incident)
override
86
{
87
const
bool
is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
88
if
(is_multiprocess && incident.type() ==
AthenaInterprocess::UpdateAfterFork::type
())
89
{
90
m_is_child
=
true
;
91
if
(!this->
initialize_worker
().isSuccess())
92
{
93
throw
GaudiException(
"Failed to initialize the XRT setup!"
,
94
"StateHandler::handle"
,
95
StatusCode::FAILURE);
96
}
97
}
98
}
99
100
virtual
~StateHandler
() =
default
;
101
102
};
103
104
}
// namespace AthXRT
105
106
#endif
//ATHXRTCORE_STATEHANDLER_H
AthCheckMacros.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
Incidents.h
AthXRT::StateHandler
Base class to provide common infrastructure for handling multiprocess state transitions for FPGA.
Definition
StateHandler.h:27
AthXRT::StateHandler::initialize
virtual StatusCode initialize()
Definition
StateHandler.h:48
AthXRT::StateHandler::handle
void handle(const Incident &incident) override
Definition
StateHandler.h:85
AthXRT::StateHandler::initialize_worker
virtual StatusCode initialize_worker()
Initialization per process.
Definition
StateHandler.h:37
AthXRT::StateHandler::stop_worker
virtual StatusCode stop_worker()
clean up
Definition
StateHandler.h:43
AthXRT::StateHandler::stop
virtual StatusCode stop()
Definition
StateHandler.h:67
AthXRT::StateHandler::m_is_child
bool m_is_child
Definition
StateHandler.h:81
AthXRT::StateHandler::initialize_global
virtual StatusCode initialize_global()
Glocal XRT initialization.
Definition
StateHandler.h:31
AthXRT::StateHandler::~StateHandler
virtual ~StateHandler()=default
AthenaInterprocess::UpdateAfterFork::type
static const std::string & type()
Incident type.
Definition
Incidents.h:49
ServiceHandle
Definition
ClusterMakerTool.h:36
AthXRT
Definition
IDeviceMgmtSvc.h:30
Generated on
for ATLAS Offline Software by
1.17.0