holoscan::PoseTreeUCXClient

Beta
View as Markdown

UCX-based client for remote PoseTree synchronization.

This class provides a client that connects to a PoseTreeUCXServer to synchronize PoseTree updates across distributed systems using UCX (Unified Communication X).

#include <holoscan/pose_tree_ucx_client.hpp>

This class is NOT thread-safe for its public methods. All public methods must be called from the same thread.


Constructors

PoseTreeUCXClient

holoscan::PoseTreeUCXClient::PoseTreeUCXClient(holoscan::PoseTreeUCXClient::PoseTreeUCXClient(
std::shared_ptr<PoseTree> pose_tree,
PoseTreeUCXClientConfig config = PoseTreeUCXClientConfig{} PoseTreeUCXClientConfig config = PoseTreeUCXClientConfig{}
)

Destructor

~PoseTreeUCXClient

holoscan::PoseTreeUCXClient::~PoseTreeUCXClient()holoscan::PoseTreeUCXClient::~PoseTreeUCXClient()

Destructor - ensures clean shutdown.

Automatically disconnects if still connected, joins the worker thread, and releases all resources. Any errors during disconnect are logged but do not throw exceptions (no-throw guarantee).


Assignment operators

operator=

The following overloads are deleted to prevent misuse:

PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(const PoseTreeUCXClient &) = delete;PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(const PoseTreeUCXClient &) = delete;PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(const PoseTreeUCXClient &) = delete;
PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(PoseTreeUCXClient &&) = delete;PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(PoseTreeUCXClient &&) = delete;PoseTreeUCXClient & holoscan::PoseTreeUCXClient::operator=(PoseTreeUCXClient &&) = delete;

Methods

connect

expected<void> holoscan::PoseTreeUCXClient::connect(
std::string_view host,
uint16_t port,
bool request_snapshot
)

Connect to a PoseTreeUCXServer.

Starts an internal worker thread that handles UCX communication with the server. The thread runs until disconnect() is called or the destructor runs.

This method blocks until the connection is established or fails

Returns: Success (void) or error status

Parameters

host
std::string_view

The hostname or IP address of the server

port
uint16_t

The port number of the server

request_snapshot
bool

Whether to request a full snapshot of the pose tree upon connection

disconnect

expected<void> holoscan::PoseTreeUCXClient::disconnect()

Disconnect from the server.

Signals the worker thread to stop, waits for it to finish (join), and cleans up all UCX resources. This method is automatically called by the destructor if needed.

This method is idempotent - calling it when already disconnected returns success

This method blocks until the worker thread has fully stopped

Returns: Success (void) or error status

is_running

bool holoscan::PoseTreeUCXClient::is_running() const

run

void holoscan::PoseTreeUCXClient::run()

Main worker thread function.

Handles UCX worker progress, processes server messages, and manages the connection. Runs in a separate thread started by connect() and stopped by disconnect().


Static methods

error_to_str

static const char * holoscan::PoseTreeUCXClient::error_to_str(
Error error
)

Convert an error code to a human readable error string.

Returns: Human-readable error string.

Parameters

error
Error

Error code to convert.


Types

Typedefs

NameDefinitionDescription
expectedholoscan::expected< T, Error >Expected type used by this class.
unexpectedholoscan::unexpected< Error >Unexpected type used by this class.

Error

Error codes used by this class.

NameValueDescription
kAlreadyConnected= 0kAlreadyConnected is returned when trying to connect while already connected
kInvalidArgument= 1kInvalidArgument is returned when invalid parameters are provided (e.g., empty host, invalid port)
kConnectionFailed= 2kConnectionFailed is returned when connection to the server fails
kNotConnected= 3kNotConnected is returned when trying to perform operations that require a connection
kThreadError= 4kThreadError is returned when thread operations fail
kShutdownError= 5kShutdownError is returned when errors occur during shutdown/disconnect
kInternalError= 6kInternalError is returned for unexpected internal errors

Member variables

NameTypeDescription
impl_std::unique_ptr< ClientImpl >Implementation details (PIMPL pattern) containing UCX objects.
pose_tree_std::shared_ptr< PoseTree >The local PoseTree instance to synchronize.
host_std::stringHostname or IP address of the server.
port_uint16_tPort number of the server.
request_snapshot_boolWhether to request a full snapshot on connection.
running_std::atomic< bool >Flag indicating if the client is running.
client_thread_std::threadThe worker thread handling UCX communication.
is_external_pose_tree_update_std::atomic< bool >Flag to prevent feedback loops during updates.
startup_callbacks_registered_std::atomic< bool >True once local PoseTree callbacks are registered.
initial_snapshot_applied_std::atomic< bool >True once the initial requested snapshot has been applied.
ready_mutex_std::mutexMutex for synchronizing connection startup.
ready_cv_std::condition_variableCondition variable for signaling connection readiness.
ready_std::atomic< bool >Flag indicating if the connection is established.
connect_failed_std::atomic< bool >Flag indicating if connection attempt failed.
config_PoseTreeUCXClientConfigConfiguration parameters for the client.