The Gaudi Framework
master (e68eea06)
Loading...
Searching...
No Matches
AsynchronousAlgorithm.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 2024-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include <
Gaudi/AsynchronousAlgorithm.h
>
12
13
#include <format>
14
15
StatusCode
Gaudi::AsynchronousAlgorithm::sysInitialize
() {
16
setAsynchronous
(
true
);
17
msg
() <<
MSG::DEBUG
<<
"Starting sysInitialize for AsynchronousAlgorithm"
<<
endmsg
;
18
return
Gaudi::Algorithm::sysInitialize
();
19
}
20
21
StatusCode
Gaudi::AsynchronousAlgorithm::sysExecute
(
const
EventContext
& ctx )
try
{
22
msg
() <<
MSG::DEBUG
<<
"Starting sysExecute for AsynchronousAlgorithm on slot "
<< ctx.slot()
23
<<
"with s_currentSlot = "
<< std::format(
"{}"
,
static_cast<
void
*
>
(
s_currentSlot
.get() ) ) <<
endmsg
;
24
if
(
s_currentSlot
.get() ==
nullptr
) {
25
s_currentSlot
.reset(
new
std::size_t( ctx.slot() ) );
26
}
else
if
( *
s_currentSlot
!= ctx.slot() ) {
27
error
() <<
"Current slot is "
<< ctx.slot() <<
" but s_currentSlot exists and is "
<< *
s_currentSlot
<<
endmsg
;
28
return
StatusCode::FAILURE
;
29
}
30
return
Gaudi::Algorithm::sysExecute
( ctx );
31
}
catch
(
const
GaudiException
& e ) {
32
error() <<
"EXCEPTION MESSAGE IS: "
<< e.
what
() <<
endmsg
;
33
throw
;
34
}
35
36
StatusCode
Gaudi::AsynchronousAlgorithm::restoreAfterSuspend
()
const
{
37
if
( !
whiteboard
()->selectStore( *s_currentSlot ).isSuccess() ) {
38
msg
() <<
MSG::ERROR
<<
"Resetting slot from fiber_specific_ptr failed"
<<
endmsg
;
39
return
StatusCode::FAILURE
;
40
}
41
return
StatusCode::SUCCESS
;
42
}
43
44
StatusCode
Gaudi::AsynchronousAlgorithm::yield
()
const
{
45
boost::this_fiber::yield();
46
return
restoreAfterSuspend
();
47
}
AsynchronousAlgorithm.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:107
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:122
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:35
Gaudi::Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition
Algorithm.cpp:322
Gaudi::Algorithm::setAsynchronous
void setAsynchronous(bool value)
Definition
Algorithm.h:378
Gaudi::Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition
Algorithm.cpp:571
Gaudi::Algorithm::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition
Algorithm.cpp:53
Gaudi::AsynchronousAlgorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
Definition
AsynchronousAlgorithm.cpp:21
Gaudi::AsynchronousAlgorithm::restoreAfterSuspend
virtual StatusCode restoreAfterSuspend() const
Restore after suspend.
Definition
AsynchronousAlgorithm.cpp:36
Gaudi::AsynchronousAlgorithm::yield
StatusCode yield() const
Forwards to boost::this_fiber::yield.
Definition
AsynchronousAlgorithm.cpp:44
Gaudi::AsynchronousAlgorithm::sysInitialize
StatusCode sysInitialize() override
Definition
AsynchronousAlgorithm.cpp:15
Gaudi::AsynchronousAlgorithm::s_currentSlot
boost::fibers::fiber_specific_ptr< std::size_t > s_currentSlot
Contains current slot.
Definition
AsynchronousAlgorithm.h:57
GaudiException
Define general base for Gaudi exception.
Definition
GaudiException.h:29
GaudiException::what
const char * what() const override
method from std::exception
Definition
GaudiException.h:108
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
MSG::DEBUG
@ DEBUG
Definition
IMessageSvc.h:22
MSG::ERROR
@ ERROR
Definition
IMessageSvc.h:22
GaudiKernel
src
Lib
AsynchronousAlgorithm.cpp
Generated on Tue Nov 18 2025 10:07:19 for The Gaudi Framework by
1.13.1