![]() |
|
|||
Warning, file /include/Gaudi/AsynchronousAlgorithm.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /***********************************************************************************\ 0002 * (c) Copyright 2023-2024 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #pragma once 0012 // ============================================================================ 0013 // Include files 0014 // ============================================================================ 0015 // Gaudi 0016 #include <Gaudi/Algorithm.h> 0017 #include <GaudiKernel/IHiveWhiteBoard.h> 0018 0019 // Others 0020 #include <boost/fiber/all.hpp> 0021 #include <chrono> 0022 0023 namespace Gaudi { 0024 /** Base class for asynchronous algorithms. 0025 * 0026 * Augments Gaudi::Algorithm by saving and restoring current slot whenever 0027 * fiber is suspended and resumed. This requires using the member functions for 0028 * suspending instead of the boost::fiber functions directly. 0029 * 0030 * @author Beojan Stanislaus 0031 * @date 2023 0032 */ 0033 0034 class GAUDI_API AsynchronousAlgorithm : public Gaudi::Algorithm { 0035 public: 0036 using Gaudi::Algorithm::Algorithm; 0037 StatusCode sysInitialize() override; 0038 StatusCode sysExecute( const EventContext& ctx ) override; 0039 0040 /// Restore after suspend 0041 virtual StatusCode restoreAfterSuspend() const; 0042 0043 /// Forwards to boost::this_fiber::yield 0044 StatusCode yield() const; 0045 0046 /// Forwards to boost::this_fiber::sleep_until 0047 template <typename Clock, typename Duration> 0048 StatusCode sleep_until( std::chrono::time_point<Clock, Duration> const& sleep_time ) const { 0049 boost::this_fiber::sleep_until( sleep_time ); 0050 return restoreAfterSuspend(); 0051 } 0052 0053 /// Forwards to boost::this_fiber::sleep_for 0054 template <typename Rep, typename Period> 0055 StatusCode sleep_for( std::chrono::duration<Rep, Period> const& dur ) const { 0056 boost::this_fiber::sleep_for( dur ); 0057 return restoreAfterSuspend(); 0058 } 0059 0060 private: 0061 /// Contains current slot 0062 boost::fibers::fiber_specific_ptr<std::size_t> s_currentSlot{}; 0063 }; 0064 } // namespace Gaudi
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |