The Gaudi Framework
master (181af51f)
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
StatusCode
Gaudi::AsynchronousAlgorithm::sysInitialize
() {
14
setAsynchronous
(
true
);
15
msg
() <<
MSG::DEBUG
<<
"Starting sysInitialize for AsynchronousAlgorithm"
<<
endmsg
;
16
return
Gaudi::Algorithm::sysInitialize
();
17
}
18
19
StatusCode
Gaudi::AsynchronousAlgorithm::sysExecute
(
const
EventContext
& ctx )
try
{
20
msg
() <<
MSG::DEBUG
<<
"Starting sysExecute for AsynchronousAlgorithm on slot "
<< ctx.slot()
21
<<
"with s_currentSlot = "
<< fmt::to_string( fmt::ptr(
s_currentSlot
.get() ) ) <<
endmsg
;
22
if
(
s_currentSlot
.get() ==
nullptr
) {
23
s_currentSlot
.reset(
new
std::size_t( ctx.slot() ) );
24
}
else
if
( *
s_currentSlot
!= ctx.slot() ) {
25
error
() <<
"Current slot is "
<< ctx.slot() <<
" but s_currentSlot exists and is "
<< *
s_currentSlot
<<
endmsg
;
26
return
StatusCode::FAILURE
;
27
}
28
return
Gaudi::Algorithm::sysExecute
( ctx );
29
}
catch
(
const
GaudiException
& e ) {
30
error() <<
"EXCEPTION MESSAGE IS: "
<< e.
what
() <<
endmsg
;
31
throw
;
32
}
33
34
StatusCode
Gaudi::AsynchronousAlgorithm::restoreAfterSuspend
()
const
{
35
if
( !
whiteboard
()->selectStore( *s_currentSlot ).isSuccess() ) {
36
msg
() <<
MSG::ERROR
<<
"Resetting slot from fiber_specific_ptr failed"
<<
endmsg
;
37
return
StatusCode::FAILURE
;
38
}
39
return
StatusCode::SUCCESS
;
40
}
41
42
StatusCode
Gaudi::AsynchronousAlgorithm::yield
()
const
{
43
boost::this_fiber::yield();
44
return
restoreAfterSuspend
();
45
}
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:34
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:19
Gaudi::AsynchronousAlgorithm::restoreAfterSuspend
virtual StatusCode restoreAfterSuspend() const
Restore after suspend.
Definition
AsynchronousAlgorithm.cpp:34
Gaudi::AsynchronousAlgorithm::yield
StatusCode yield() const
Forwards to boost::this_fiber::yield.
Definition
AsynchronousAlgorithm.cpp:42
Gaudi::AsynchronousAlgorithm::sysInitialize
StatusCode sysInitialize() override
Definition
AsynchronousAlgorithm.cpp:13
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 Wed Oct 8 2025 09:53:37 for The Gaudi Framework by
1.13.1