Loading...
Searching...
No Matches
ucxx::WorkerBuilder Class Referencefinal

Builder class for constructing std::shared_ptr<ucxx::Worker> objects. More...

#include <worker_builder.h>

Public Member Functions

 WorkerBuilder (std::shared_ptr< Context > context)
 Constructor for WorkerBuilder with required context.
 ~WorkerBuilder ()
 WorkerBuilder destructor.
 WorkerBuilder (const WorkerBuilder &other)
 Copy constructor (deep-copies internal state).
WorkerBuilder & operator= (const WorkerBuilder &other)
 Copy assignment operator (deep-copies internal state).
 WorkerBuilder (WorkerBuilder &&) noexcept
 Move constructor.
WorkerBuilder & operator= (WorkerBuilder &&) noexcept
 Move assignment operator.
 operator std::shared_ptr< Worker > ()
 Implicit conversion operator to shared_ptr<Worker>.
WorkerBuilder & delayedSubmission (bool enable=true)
 Configure delayed submission to the progress thread.
WorkerBuilder & pythonFuture (bool enable=true)
 Configure Python future support.
WorkerBuilder & requestAttributes (bool enable=true)
 Configure request attributes querying.
WorkerBuilder & cudaBufferType (BufferType bufferType)
 Configure the preferred buffer type for CUDA allocations.
std::shared_ptr< Worker > build ()
 Build and return the Worker.

Detailed Description

Builder class for constructing std::shared_ptr<ucxx::Worker> objects.

This class implements the builder pattern for std::shared_ptr<ucxx::Worker>, allowing optional parameters to be specified via method chaining. Construction happens when the builder expression completes (via implicit conversion) or when build() is called.

The context is required and must be provided to workerBuilder(). The delayedSubmission() and pythonFuture() methods are optional.

WorkerBuilder objects are not thread-safe. Accessing the same builder object from multiple threads requires external synchronization. Distinct builder objects are independent.

// Minimal usage (no options enabled)
auto worker = ucxx::workerBuilder(context).build();
// With optional parameters
auto worker = ucxx::workerBuilder(context)
.pythonFuture(true)
.build();
// Using implicit conversion
std::shared_ptr<ucxx::Worker> worker = ucxx::workerBuilder(context);
std::shared_ptr< Worker > build()
Build and return the Worker.
WorkerBuilder & pythonFuture(bool enable=true)
Configure Python future support.
WorkerBuilder & delayedSubmission(bool enable=true)
Configure delayed submission to the progress thread.
WorkerBuilder workerBuilder(std::shared_ptr< Context > context)
Create a WorkerBuilder for constructing a shared_ptr<ucxx::Worker>.
Definition worker_builder.h:158

Constructor & Destructor Documentation

◆ WorkerBuilder()

ucxx::WorkerBuilder::WorkerBuilder ( std::shared_ptr< Context > context)
explicit

Constructor for WorkerBuilder with required context.

Parameters
[in]contextcontext from which the worker will be created (required).

Member Function Documentation

◆ build()

std::shared_ptr< Worker > ucxx::WorkerBuilder::build ( )
nodiscard

Build and return the Worker.

This method constructs the Worker with the specified parameters and returns it. Each call to build() creates a new Worker instance with the current parameters.

Returns
The constructed shared_ptr<ucxx::Worker> object.

◆ cudaBufferType()

WorkerBuilder & ucxx::WorkerBuilder::cudaBufferType ( BufferType bufferType)

Configure the preferred buffer type for CUDA allocations.

Parameters
[in]bufferTypethe preferred buffer type for CUDA allocations.
Returns
Reference to this builder for method chaining.

◆ delayedSubmission()

WorkerBuilder & ucxx::WorkerBuilder::delayedSubmission ( bool enable = true)

Configure delayed submission to the progress thread.

Parameters
[in]enablewhether delayed submission is enabled (default: true).
Returns
Reference to this builder for method chaining.

◆ operator std::shared_ptr< Worker >()

ucxx::WorkerBuilder::operator std::shared_ptr< Worker > ( )

Implicit conversion operator to shared_ptr<Worker>.

Enables automatic construction of the Worker when the builder is used in a context requiring a shared_ptr<Worker>, delegating to build().

Returns
The constructed shared_ptr<ucxx::Worker> object.

◆ pythonFuture()

WorkerBuilder & ucxx::WorkerBuilder::pythonFuture ( bool enable = true)

Configure Python future support.

Parameters
[in]enablewhether Python futures are enabled (default: true).
Returns
Reference to this builder for method chaining.

◆ requestAttributes()

WorkerBuilder & ucxx::WorkerBuilder::requestAttributes ( bool enable = true)

Configure request attributes querying.

When enabled, each ucxx::Request created from the worker will have its UCP attributes (such as the debug string) queried immediately after submission, making them available via ucxx::Request::getRequestAttributes(). This may have non-negligible runtime cost and is therefore disabled by default.

Parameters
[in]enablewhether request attributes querying is enabled (default: true).
Returns
Reference to this builder for method chaining.

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