All Classes Namespaces Functions Variables Typedefs Enumerations Friends
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
 
WorkerProgressThreadoperator= (WorkerProgressThread &&o)=default
 
 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 shared_ptr<ucxx::Worker>. 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 ()
 

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()

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 shared_ptr<ucxx::Worker>.

The constructor for a shared_ptr<ucxx::Worker> 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]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]signalWorkerFunctionuser-defined function to wake the worker progress event (when pollingMode is false).
[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.

◆ pollingMode()

bool ucxx::WorkerProgressThread::pollingMode ( ) const

Returns whether the thread was created for polling progress mode.

Returns
Whether polling mode is enabled.

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