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

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

#include <context_builder.h>

Public Member Functions

 ContextBuilder (uint64_t featureFlags)
 Constructor for ContextBuilder with required feature flags. More...
 
ContextBuilderconfigMap (ConfigMap configMap)
 Set the configuration map for the context. More...
 
std::shared_ptr< Contextbuild () const
 Build and return the Context. More...
 
 operator std::shared_ptr< Context > () const
 Implicit conversion operator to shared_ptr<Context>. More...
 

Detailed Description

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

This class implements the builder pattern for std::shared_ptr<ucxx::Context>, allowing optional parameters to be specified via method chaining. Construction happens immediately when the builder expression completes, ensuring one-time construction with immediate evaluation.

The feature flags are required and must be provided to createContext(). The configMap() method is optional.

// Minimal usage (only featureFlags required)
auto ctx = ucxx::experimental::createContext(UCP_FEATURE_TAG | UCP_FEATURE_WAKEUP).build();
// With optional configMap
auto context = ucxx::experimental::createContext(UCP_FEATURE_TAG | UCP_FEATURE_WAKEUP)
.configMap({{"TLS", "tcp"}})
.build();
// Using implicit conversion
std::shared_ptr<ucxx::Context> ctx = ucxx::experimental::createContext(UCP_FEATURE_RMA);
ContextBuilder & configMap(ConfigMap configMap)
Set the configuration map for the context.
std::shared_ptr< Context > build() const
Build and return the Context.

Constructor & Destructor Documentation

◆ ContextBuilder()

ucxx::experimental::ContextBuilder::ContextBuilder ( uint64_t  featureFlags)
explicit

Constructor for ContextBuilder with required feature flags.

Parameters
[in]featureFlagsfeature flags to be used at UCP context construction time (required).

Member Function Documentation

◆ build()

std::shared_ptr<Context> ucxx::experimental::ContextBuilder::build ( ) const

Build and return the Context.

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

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

◆ configMap()

ContextBuilder& ucxx::experimental::ContextBuilder::configMap ( ConfigMap  configMap)

Set the configuration map for the context.

Parameters
[in]configMapconfigurations overriding UCX_* defaults and environment variables.
Returns
Reference to this builder for method chaining.

◆ operator std::shared_ptr< Context >()

ucxx::experimental::ContextBuilder::operator std::shared_ptr< Context > ( ) const

Implicit conversion operator to shared_ptr<Context>.

This operator enables automatic construction of the Context when the builder is used in a context requiring a shared_ptr<Context>. This allows seamless use with auto variables.

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

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