Public Member Functions | List of all members
ucxx::WorkerProgressThread Class Reference

A thread to progress a ucxx::Worker. More...

#include <worker_progress_thread.h>

Public Member Functions

 WorkerProgressThread (const WorkerProgressThread &)=delete
 
WorkerProgressThreadoperator= (WorkerProgressThread const &)=delete
 
 WorkerProgressThread (WorkerProgressThread &&o)=default
 Move constructor of WorkerProgressThread. More...
 
WorkerProgressThreadoperator= (WorkerProgressThread &&o)=default
 Move assignment operator of WorkerProgressThread. More...
 
 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. More...
 
 ~WorkerProgressThread ()
 ucxx::WorkerProgressThread destructor. More...
 
bool pollingMode () const
 Returns whether the thread was created for polling progress mode. More...
 
std::thread::id getId () const
 Returns the ID of the progress thread. More...
 
bool isRunning () const
 Returns whether the thread is running. More...
 
void stop ()
 Stop the progress thread. More...
 

Detailed Description

A thread to progress a ucxx::Worker.

A thread to progress the ucxx::Worker, thus moving all such blocking operations out of the main program thread. It may also be used to execute submissions, such as from ucxx::Request objects, therefore also moving any blocking costs of those to this thread, as well as generic pre-progress and post-progress callbacks that can be used by the program to block until that stage is reached.

Constructor & Destructor Documentation

◆ WorkerProgressThread() [1/2]

ucxx::WorkerProgressThread::WorkerProgressThread ( WorkerProgressThread &&  o)
default

Move constructor of WorkerProgressThread.

Transfers ownership of the progress thread resources from the source object to the newly constructed object. The source object is left in a valid but unspecified state.

Parameters
[in]othe source object to move from.

◆ WorkerProgressThread() [2/2]

ucxx::WorkerProgressThread::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.

The constructor for a WorkerProgressThread object. The default constructor is made private to ensure all UCXX objects are shared pointers for correct lifetime management.

This thread runs asynchronously with the main application thread. If you require cross-thread synchronization (for example when tearing down the thread or canceling requests), use the generic pre and post callbacks with a CallbackNotifier that synchronizes with the application thread. Since the worker progress itself may change state, it is usually the case that synchronization is needed in both pre and post callbacks.

// context is `std::shared_ptr<ucxx::Context>`
auto worker = context->createWorker(false);
// Equivalent to line above
// auto worker = ucxx::createWorker(context, false);
Parameters
[in]pollingModewhether the thread should use polling mode to progress.
[in]progressFunctionuser-defined progress function implementation.
[in]signalWorkerFunctionuser-defined function to wake the worker progress event (when pollingMode is false).
[in]setThreadIdcallback function executed before the startCallback with a purpose of setting the thread ID with the parent so it is known before the progress loop starts.
[in]startCallbackuser-defined callback function to be executed at the start of the progress thread.
[in]startCallbackArgan argument to be passed to the start callback.
[in]delayedSubmissionCollectioncollection of delayed submissions to be processed during progress.

◆ ~WorkerProgressThread()

ucxx::WorkerProgressThread::~WorkerProgressThread ( )

ucxx::WorkerProgressThread destructor.

Raises the stop signal and joins the thread.

Member Function Documentation

◆ getId()

std::thread::id ucxx::WorkerProgressThread::getId ( ) const

Returns the ID of the progress thread.

Returns
the progress thread ID.

◆ isRunning()

bool ucxx::WorkerProgressThread::isRunning ( ) const

Returns whether the thread is running.

Returns
Whether the thread is running.

◆ operator=()

WorkerProgressThread& ucxx::WorkerProgressThread::operator= ( WorkerProgressThread &&  o)
default

Move assignment operator of WorkerProgressThread.

Transfers ownership of the progress thread resources from the source object to the target object. The source object is left in a valid but unspecified state.

Parameters
[in]othe source object to move from.
Returns
reference to the target object.

◆ pollingMode()

bool ucxx::WorkerProgressThread::pollingMode ( ) const

Returns whether the thread was created for polling progress mode.

Returns
Whether polling mode is enabled.

◆ stop()

void ucxx::WorkerProgressThread::stop ( )

Stop the progress thread.

Raises the stop signal and joins the thread.


The documentation for this class was generated from the following file: