The Gaudi Framework
master (53dee381)
Toggle main menu visibility
Loading...
Searching...
No Matches
AsynchronousAlgorithm.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 2023-2026 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
#pragma once
12
13
#include <
Gaudi/Algorithm.h
>
14
#include <
Gaudi/Property.h
>
15
#include <
GaudiKernel/Guards.h
>
16
#include <
GaudiKernel/ITimelineSvc.h
>
17
18
#include <boost/fiber/fss.hpp>
// for fiber_specific_ptr
19
#include <boost/fiber/operations.hpp>
// for this_fiber
20
#include <chrono>
21
22
namespace
Gaudi
{
32
33
class
GAUDI_API
AsynchronousAlgorithm
:
public
Gaudi::Algorithm
{
34
public
:
35
using
Gaudi::Algorithm::Algorithm
;
36
StatusCode
sysInitialize
()
override
;
37
StatusCode
sysExecute
(
const
EventContext
& ctx )
override
;
38
40
[[deprecated(
"Wrap suspending or possibly suspending calls with `decorateSuspension` instead of following them "
41
"with a call to `restoreAfterSuspend`."
)]]
virtual
StatusCode
42
restoreAfterSuspend
()
const
;
43
46
StatusCode
decorateSuspension
( std::function<
StatusCode
()> f )
const
;
47
49
StatusCode
yield
()
const
;
50
52
template
<
typename
Clock,
typename
Duration>
53
StatusCode
sleep_until
( std::chrono::time_point<Clock, Duration>
const
& sleep_time )
const
{
54
return
decorateSuspension
( [sleep_time]() {
55
boost::this_fiber::sleep_until( sleep_time );
56
return
StatusCode::SUCCESS
;
57
} );
58
}
59
61
template
<
typename
Rep,
typename
Period>
62
StatusCode
sleep_for
( std::chrono::duration<Rep, Period>
const
& dur )
const
{
63
return
decorateSuspension
( [dur]() {
64
boost::this_fiber::sleep_for( dur );
65
return
StatusCode::SUCCESS
;
66
} );
67
}
68
69
protected
:
70
virtual
StatusCode
preSuspension()
const
;
71
virtual
StatusCode
postResumption()
const
;
72
73
private
:
75
boost::fibers::fiber_specific_ptr<EventContext>
s_ctx
{};
76
mutable
boost::fibers::fiber_specific_ptr<ITimelineSvc::TimelineRecorder>
s_timelineRecorder
{};
77
78
// Flag to control asynchronous timeline recording
79
bool
m_doAsyncTimeline
{
false
};
80
81
Gaudi::Property<bool>
m_auditorSuspension
{
this
,
"AuditSuspension"
,
82
Details::getDefaultAuditorValue
(
serviceLocator
() ),
83
"trigger auditor on suspension of execution"
};
84
};
85
}
// namespace Gaudi
Algorithm.h
Property.h
Guards.h
ITimelineSvc.h
GAUDI_API
#define GAUDI_API
Definition
Kernel.h:49
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:35
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition
Algorithm.h:87
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition
Algorithm.h:98
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Algorithm.cpp:562
Gaudi::AsynchronousAlgorithm
Base class for asynchronous algorithms.
Definition
AsynchronousAlgorithm.h:33
Gaudi::AsynchronousAlgorithm::m_auditorSuspension
Gaudi::Property< bool > m_auditorSuspension
Definition
AsynchronousAlgorithm.h:81
Gaudi::AsynchronousAlgorithm::s_ctx
boost::fibers::fiber_specific_ptr< EventContext > s_ctx
Contains current slot.
Definition
AsynchronousAlgorithm.h:75
Gaudi::AsynchronousAlgorithm::sleep_until
StatusCode sleep_until(std::chrono::time_point< Clock, Duration > const &sleep_time) const
Forwards to boost::this_fiber::sleep_until.
Definition
AsynchronousAlgorithm.h:53
Gaudi::AsynchronousAlgorithm::m_doAsyncTimeline
bool m_doAsyncTimeline
Definition
AsynchronousAlgorithm.h:79
Gaudi::AsynchronousAlgorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
Definition
AsynchronousAlgorithm.cpp:24
Gaudi::AsynchronousAlgorithm::restoreAfterSuspend
virtual StatusCode restoreAfterSuspend() const
Restore after suspend.
Definition
AsynchronousAlgorithm.cpp:44
Gaudi::AsynchronousAlgorithm::yield
StatusCode yield() const
Forwards to boost::this_fiber::yield.
Definition
AsynchronousAlgorithm.cpp:108
Gaudi::AsynchronousAlgorithm::sysInitialize
StatusCode sysInitialize() override
Definition
AsynchronousAlgorithm.cpp:15
Gaudi::AsynchronousAlgorithm::decorateSuspension
StatusCode decorateSuspension(std::function< StatusCode()> f) const
Decorate a direct call to a suspending (or possibly suspending) function with the necessary pre- and ...
Definition
AsynchronousAlgorithm.cpp:75
Gaudi::AsynchronousAlgorithm::sleep_for
StatusCode sleep_for(std::chrono::duration< Rep, Period > const &dur) const
Forwards to boost::this_fiber::sleep_for.
Definition
AsynchronousAlgorithm.h:62
Gaudi::AsynchronousAlgorithm::s_timelineRecorder
boost::fibers::fiber_specific_ptr< ITimelineSvc::TimelineRecorder > s_timelineRecorder
Definition
AsynchronousAlgorithm.h:76
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
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
Gaudi::Details::getDefaultAuditorValue
bool getDefaultAuditorValue(ISvcLocator *loc)
Definition
Algorithm.cpp:44
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
GaudiKernel
include
Gaudi
AsynchronousAlgorithm.h
Generated on
for The Gaudi Framework by
1.17.0