The Gaudi Framework
master (37c0b60a)
PeriodicAction.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 2024 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 <chrono>
14
#include <functional>
15
#include <future>
16
#include <thread>
17
18
namespace
Gaudi::Utils
{
29
class
PeriodicAction
{
30
public
:
31
using
clock
=
std::chrono::system_clock
;
32
using
time_point
= clock::time_point;
33
using
callback_t
=
std::function
<void()>;
34
35
PeriodicAction
(
callback_t
callback
,
std::chrono::milliseconds
period_duration,
bool
autostart =
true
);
36
PeriodicAction
(
PeriodicAction
&& ) =
default
;
37
PeriodicAction
&
operator=
(
PeriodicAction
&& ) =
default
;
38
39
~PeriodicAction
();
40
41
void
start
();
42
void
stop
();
43
44
private
:
45
std::thread
m_thread
;
46
std::promise<void>
m_stop_thread
;
47
callback_t
m_callback
;
48
std::chrono::milliseconds
m_period_duration
;
49
};
50
}
// namespace Gaudi::Utils
std::chrono::system_clock
Gaudi::Utils::PeriodicAction::stop
void stop()
Definition:
PeriodicAction.cpp:41
Gaudi::Utils::PeriodicAction::~PeriodicAction
~PeriodicAction()
Definition:
PeriodicAction.cpp:21
Gaudi::Utils::PeriodicAction::m_stop_thread
std::promise< void > m_stop_thread
Definition:
PeriodicAction.h:46
std::promise< void >
std::chrono::milliseconds
std::function< void()>
Gaudi::Utils::PeriodicAction::m_period_duration
std::chrono::milliseconds m_period_duration
Definition:
PeriodicAction.h:48
Gaudi::Utils
Definition:
Property.h:650
Gaudi::Utils::PeriodicAction
Helper to periodically run asynchronous tasks.
Definition:
PeriodicAction.h:29
std::thread
STL class.
Gaudi::Utils::PeriodicAction::PeriodicAction
PeriodicAction(callback_t callback, std::chrono::milliseconds period_duration, bool autostart=true)
Definition:
PeriodicAction.cpp:16
Gaudi::Utils::PeriodicAction::m_callback
callback_t m_callback
Definition:
PeriodicAction.h:47
Gaudi::Utils::PeriodicAction::m_thread
std::thread m_thread
Definition:
PeriodicAction.h:45
Gaudi::Utils::PeriodicAction::operator=
PeriodicAction & operator=(PeriodicAction &&)=default
Gaudi::Utils::PeriodicAction::start
void start()
Definition:
PeriodicAction.cpp:23
Gaudi::Utils::PeriodicAction::time_point
clock::time_point time_point
Definition:
PeriodicAction.h:32
Gaudi::Utils::PeriodicAction::PeriodicAction
PeriodicAction(PeriodicAction &&)=default
gaudirun.callback
callback
Definition:
gaudirun.py:202
GaudiUtils
include
Gaudi
Utils
PeriodicAction.h
Generated on Thu Dec 19 2024 15:35:07 for The Gaudi Framework by
1.8.18