Endpoint Close Request#

2026-03-31

5 min read time

Applies to Linux

The ucxx::RequestEndpointClose class implements a non-blocking endpoint close operation. Closing an endpoint gracefully terminates the connection and releases associated resources.

#include <ucxx/request_endpoint_close.h>

namespace ucxx

class RequestEndpointClose : public ucxx::Request#

Send or receive a message with the UCX Tag API.

Close a UCP endpoint, using non-blocking UCP call ucp_ep_close_nbx.

Public Functions

virtual void populateDelayedSubmission(
)#

Populate the internal submission dispatcher.

The ucxx::Request utilizes ucxx::DelayedSubmission to manage when the request will be dispatched. This method is registered as a callback in the worker, that may choose to either execute (submit) it immediately or delay for the next iteration of its progress loop, depending on the progress mode in use by the worker.

See ucxx::DelayedSubmission::DelayedSubmission() for more details.

void request(
)#

Create and submit an endpoint close request.

This is the method that should be called to actually submit an endpoint close request. It is meant to be called from populateDelayedSubmission(), which is decided at the discretion of std::shared_ptr<ucxx::Worker>. See populateDelayedSubmission() for more details.

Public Static Functions

static void endpointCloseCallback(
void *request,
ucs_status_t status,
void *arg
)#

Callback executed by UCX when an endpoint close request is completed.

Callback executed by UCX when an endpoint close request is completed, that will dispatch ucxx::Request::callback().

Warning

This is not intended to be called by the user, but it currently needs to be a public method so that UCX may access it. In future changes this will be moved to an internal object and remove this method from the public API.

Parameters:
  • request[in] the UCX request pointer.

  • status[in] the completion status of the request.

  • arg[in] the pointer to the ucxx::Request object that created the transfer, effectively this pointer as seen by request().

Friends

friend std::shared_ptr<RequestEndpointClose> createRequestEndpointClose(
std::shared_ptr<Endpoint> endpoint,
const data::EndpointClose requestData,
const bool enablePythonFuture,
RequestCallbackUserFunction callbackFunction,
RequestCallbackUserData callbackData
)#

Constructor for std::shared_ptr<ucxx::RequestEndpointClose>.

The constructor for a std::shared_ptr<ucxx::RequestEndpointClose> object, creating a request to close a UCP endpoint, returning a pointer to the request object that can be later awaited and checked for errors. This is a non-blocking operation, and its status must be verified from the resulting request object to confirm the close operation has completed successfully.

Note

If a callbackFunction is specified, the lifetime of callbackData and of any other objects used in the scope of callbackFunction must be guaranteed by the caller until it executes or isCompleted() becomes true. The callbackFunction executes in the thread progressing the ucxx::Worker, unless the request completes immediately, in which case the callback will also execute immediately within the calling thread and before the method returns.

Throws:

ucxx::Errorendpoint is not a valid std::shared_ptr<ucxx::Endpoint>.

Parameters:
  • endpoint[in] the std::shared_ptr<Endpoint> parent component.

  • requestData[in] container of the specified message type, including all type-specific data.

  • enablePythonFuture[in] whether a python future should be created and subsequently notified.

  • callbackFunction[in] user-defined callback function to call upon completion.

  • callbackData[in] user-defined data to pass to the callbackFunction.

Returns:

The shared_ptr<ucxx::RequestEndpointClose> object.

Factory Functions#

#include <ucxx/constructors.h>

std::shared_ptr<RequestEndpointClose> ucxx::createRequestEndpointClose(
std::shared_ptr<Endpoint> endpoint,
const data::EndpointClose requestData,
const bool enablePythonFuture,
RequestCallbackUserFunction callbackFunction,
RequestCallbackUserData callbackData
)#

The constructor for a std::shared_ptr<ucxx::RequestEndpointClose> object, creating a request to close a UCP endpoint, returning a pointer to the request object that can be later awaited and checked for errors. This is a non-blocking operation, and its status must be verified from the resulting request object to confirm the close operation has completed successfully.

Note

If a callbackFunction is specified, the lifetime of callbackData and of any other objects used in the scope of callbackFunction must be guaranteed by the caller until it executes or isCompleted() becomes true. The callbackFunction executes in the thread progressing the ucxx::Worker, unless the request completes immediately, in which case the callback will also execute immediately within the calling thread and before the method returns.

Throws:

ucxx::Errorendpoint is not a valid std::shared_ptr<ucxx::Endpoint>.

Parameters:
  • endpoint[in] the std::shared_ptr<Endpoint> parent component.

  • requestData[in] container of the specified message type, including all type-specific data.

  • enablePythonFuture[in] whether a python future should be created and subsequently notified.

  • callbackFunction[in] user-defined callback function to call upon completion.

  • callbackData[in] user-defined data to pass to the callbackFunction.

Returns:

The shared_ptr<ucxx::RequestEndpointClose> object.