14#include <ucxx/delayed_submission.h>
50class WorkerProgressThread {
75 std::thread _thread{};
76 std::shared_ptr<std::atomic<bool>> _stop{
77 std::make_shared<std::atomic<bool>>(
false)};
78 bool _pollingMode{
false};
86 std::shared_ptr<DelayedSubmissionCollection> _delayedSubmissionCollection{
110 static void progressUntilSync(
111 std::function<
bool(
void)> progressFunction,
112 std::shared_ptr<std::atomic<bool>>
stop,
113 std::function<
void(
void)> setThreadId,
116 std::shared_ptr<DelayedSubmissionCollection> delayedSubmissionCollection);
119 WorkerProgressThread() =
default;
120 WorkerProgressThread(
const WorkerProgressThread&) =
delete;
121 WorkerProgressThread& operator=(WorkerProgressThread
const&) =
delete;
142 WorkerProgressThread&
operator=(WorkerProgressThread&& o) =
default;
182 std::function<
bool(
void)> progressFunction,
183 std::function<
void(
void)> signalWorkerFunction,
184 std::function<
void(
void)> setThreadId,
187 std::shared_ptr<DelayedSubmissionCollection> delayedSubmissionCollection);
208 [[nodiscard]] std::thread::id
getId()
const;
WorkerProgressThread(const bool pollingMode, std::function< bool(void)> progressFunction, std::function< void(void)> signalWorkerFunction, std::function< void(void)> setThreadId, ProgressThreadStartCallback startCallback, ProgressThreadStartCallbackArg startCallbackArg, std::shared_ptr< DelayedSubmissionCollection > delayedSubmissionCollection)
Constructor of WorkerProgressThread.
std::thread::id getId() const
Returns the ID of the progress thread.
~WorkerProgressThread()
ucxx::WorkerProgressThread destructor.
bool isRunning() const
Returns whether the thread is running.
void stop(StopConfig stopConfig=StopConfig{})
Stop the progress thread.
WorkerProgressThread & operator=(WorkerProgressThread &&o)=default
Move assignment operator of WorkerProgressThread.
WorkerProgressThread(WorkerProgressThread &&o)=default
Move constructor of WorkerProgressThread.
bool pollingMode() const
Returns whether the thread was created for polling progress mode.
std::function< void(void *)> ProgressThreadStartCallback
A user-defined function to execute at the start of the progress thread.
Definition worker_progress_thread.h:31
void * ProgressThreadStartCallbackArg
Data for the user-defined function provided to progress thread start callback.
Definition worker_progress_thread.h:39
std::function< void(void)> SignalWorkerFunction
A user-defined function used to wake the worker.
Definition worker_progress_thread.h:23
Progress thread stop synchronization configuration.
Definition worker_progress_thread.h:55
uint64_t signalIntervalNs
Interval for waking the worker while waiting.
Definition worker_progress_thread.h:57
StopConfig(uint64_t callbackTimeoutNs=3000000000, uint64_t signalIntervalNs=100000000)
Create stop synchronization configuration.
Definition worker_progress_thread.h:67
uint64_t callbackTimeoutNs
Maximum time to wait for each stop callback.
Definition worker_progress_thread.h:56