DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
utilities
include
utilities
WorkerThread.hpp
Go to the documentation of this file.
1
15
16
#ifndef UTILITIES_INCLUDE_UTILITIES_WORKERTHREAD_HPP_
17
#define UTILITIES_INCLUDE_UTILITIES_WORKERTHREAD_HPP_
18
19
#include "
ers/ers.hpp
"
20
#include "
logging/Logging.hpp
"
// NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
21
22
#include <functional>
23
#include <future>
24
#include <list>
25
#include <memory>
26
#include <string>
27
28
namespace
dunedaq::utilities
{
63
class
WorkerThread
64
{
65
public
:
72
explicit
WorkerThread
(std::function<
void
(std::atomic<bool>&)> do_work);
73
78
void
start_working_thread
(
const
std::string& name =
"noname"
);
85
void
stop_working_thread
();
86
91
bool
thread_running
()
const
{
return
m_thread_running
.load(); }
92
93
WorkerThread
(
const
WorkerThread
&) =
delete
;
94
WorkerThread
&
operator=
(
const
WorkerThread
&) =
delete
;
95
WorkerThread
(
WorkerThread
&&) =
delete
;
96
WorkerThread
&
operator=
(
WorkerThread
&&) =
delete
;
97
98
private
:
99
std::atomic<bool>
m_thread_running
;
100
std::unique_ptr<std::jthread>
m_working_thread
;
101
std::function<void(std::atomic<bool>&)>
m_do_work
;
102
};
103
}
// namespace dunedaq::utilities
104
105
#endif
// UTILITIES_INCLUDE_UTILITIES_WORKERTHREAD_HPP_
dunedaq::utilities::WorkerThread::m_working_thread
std::unique_ptr< std::jthread > m_working_thread
Definition
WorkerThread.hpp:100
dunedaq::utilities::WorkerThread::stop_working_thread
void stop_working_thread()
Stop the working thread.
Definition
WorkerThread.cpp:47
dunedaq::utilities::WorkerThread::WorkerThread
WorkerThread(WorkerThread &&)=delete
WorkerThread is not move-constructible.
dunedaq::utilities::WorkerThread::start_working_thread
void start_working_thread(const std::string &name="noname")
Start the working thread (which executes the do_work() function).
Definition
WorkerThread.cpp:28
dunedaq::utilities::WorkerThread::operator=
WorkerThread & operator=(WorkerThread &&)=delete
WorkerThread is not move-assignable.
dunedaq::utilities::WorkerThread::m_thread_running
std::atomic< bool > m_thread_running
Definition
WorkerThread.hpp:99
dunedaq::utilities::WorkerThread::operator=
WorkerThread & operator=(const WorkerThread &)=delete
WorkerThread is not copy-assginable.
dunedaq::utilities::WorkerThread::thread_running
bool thread_running() const
Determine if the thread is currently running.
Definition
WorkerThread.hpp:91
dunedaq::utilities::WorkerThread::WorkerThread
WorkerThread(const WorkerThread &)=delete
WorkerThread is not copy-constructible.
dunedaq::utilities::WorkerThread::m_do_work
std::function< void(std::atomic< bool > &)> m_do_work
Definition
WorkerThread.hpp:101
dunedaq::utilities::WorkerThread::WorkerThread
WorkerThread(std::function< void(std::atomic< bool > &)> do_work)
WorkerThread Constructor.
Definition
WorkerThread.cpp:20
ers.hpp
Logging.hpp
dunedaq::utilities
Definition
TimestampEstimatorTimeSync.hxx:3
Generated on
for DUNE-DAQ by
1.17.0