The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
AsynchronousAlgorithm.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 2023-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#pragma once
12
13#include <Gaudi/Algorithm.h>
15#include <boost/fiber/all.hpp>
16#include <chrono>
17
18namespace Gaudi {
28
30 public:
32 StatusCode sysInitialize() override;
33 StatusCode sysExecute( const EventContext& ctx ) override;
34
36 virtual StatusCode restoreAfterSuspend() const;
37
39 StatusCode yield() const;
40
42 template <typename Clock, typename Duration>
43 StatusCode sleep_until( std::chrono::time_point<Clock, Duration> const& sleep_time ) const {
44 boost::this_fiber::sleep_until( sleep_time );
45 return restoreAfterSuspend();
46 }
47
49 template <typename Rep, typename Period>
50 StatusCode sleep_for( std::chrono::duration<Rep, Period> const& dur ) const {
51 boost::this_fiber::sleep_for( dur );
52 return restoreAfterSuspend();
53 }
54
55 private:
57 boost::fibers::fiber_specific_ptr<std::size_t> s_currentSlot{};
58 };
59} // namespace Gaudi
#define GAUDI_API
Definition Kernel.h:49
This class represents an entry point to all the event specific data.
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:87
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
Base class for asynchronous algorithms.
StatusCode sleep_until(std::chrono::time_point< Clock, Duration > const &sleep_time) const
Forwards to boost::this_fiber::sleep_until.
StatusCode sysExecute(const EventContext &ctx) override
virtual StatusCode restoreAfterSuspend() const
Restore after suspend.
StatusCode yield() const
Forwards to boost::this_fiber::yield.
StatusCode sleep_for(std::chrono::duration< Rep, Period > const &dur) const
Forwards to boost::this_fiber::sleep_for.
boost::fibers::fiber_specific_ptr< std::size_t > s_currentSlot
Contains current slot.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1