libucxx  0.37.00
All Classes Namespaces Functions Variables Typedefs Enumerations Friends
worker_progress_thread.h
1 
5 #pragma once
6 
7 #include <functional>
8 #include <memory>
9 #include <mutex>
10 #include <thread>
11 
12 #include <ucxx/delayed_submission.h>
13 
14 namespace ucxx {
15 
21 typedef std::function<void(void)> SignalWorkerFunction;
22 
29 typedef std::function<void(void*)> ProgressThreadStartCallback;
30 
38 
49  private:
50  std::thread _thread{};
51  bool _stop{false};
52  bool _pollingMode{false};
53  SignalWorkerFunction _signalWorkerFunction{
54  nullptr};
56  ProgressThreadStartCallback _startCallback{
57  nullptr};
58  ProgressThreadStartCallbackArg _startCallbackArg{
59  nullptr};
60  std::shared_ptr<DelayedSubmissionCollection> _delayedSubmissionCollection{
61  nullptr};
62 
80  static void progressUntilSync(
81  std::function<bool(void)> progressFunction,
82  const bool& stop,
83  ProgressThreadStartCallback startCallback,
84  ProgressThreadStartCallbackArg startCallbackArg,
85  std::shared_ptr<DelayedSubmissionCollection> delayedSubmissionCollection);
86 
87  public:
88  WorkerProgressThread() = delete;
89 
124  std::function<bool(void)> progressFunction,
125  std::function<void(void)> signalWorkerFunction,
126  ProgressThreadStartCallback startCallback,
127  ProgressThreadStartCallbackArg startCallbackArg,
128  std::shared_ptr<DelayedSubmissionCollection> delayedSubmissionCollection);
129 
136 
142  bool pollingMode() const;
143 
149  std::thread::id getId() const;
150 };
151 
152 } // namespace ucxx
A thread to progress a ucxx::Worker.
Definition: worker_progress_thread.h:48
std::thread::id getId() const
Returns the ID of the progress thread.
~WorkerProgressThread()
ucxx::WorkerProgressThread destructor.
WorkerProgressThread(const bool pollingMode, std::function< bool(void)> progressFunction, std::function< void(void)> signalWorkerFunction, ProgressThreadStartCallback startCallback, ProgressThreadStartCallbackArg startCallbackArg, std::shared_ptr< DelayedSubmissionCollection > delayedSubmissionCollection)
Constructor of shared_ptr<ucxx::Worker>.
bool pollingMode() const
Returns whether the thread was created for polling progress mode.
Definition: address.h:15
std::function< void(void *)> ProgressThreadStartCallback
A user-defined function to execute at the start of the progress thread.
Definition: worker_progress_thread.h:29
void * ProgressThreadStartCallbackArg
Data for the user-defined function provided to progress thread start callback.
Definition: worker_progress_thread.h:37
std::function< void(void)> SignalWorkerFunction
A user-defined function used to wake the worker.
Definition: worker_progress_thread.h:21