Notifier#
2026-03-31
3 min read time
The ucxx::Notifier class provides a mechanism for notifying external components
when UCXX requests complete. It is used by the worker progress thread to signal
request completion to consumers such as the Python event loop.
#include <ucxx/notifier.h>
namespace ucxx
-
class Notifier#
Notifier for status of futures.
A notifier used to delay notification of futures to a more appropriate stage of the program execution, such as when it will be less resource intensive or free of risks of effects such as deadlocks, for example when notifying Python futures where the GIL is required.
Subclassed by ucxx::python::Notifier
Public Functions
- inline virtual ~Notifier(
Virtual destructor.
Virtual destructor with empty implementation.
- std::shared_ptr<Future> future,
- ucs_status_t status
Schedule notification of completed future.
Schedule the notification of a completed Python future, but does not set the future’s result yet, which is later done by
runRequestNotifier(). Because this call does not notify the future, it does not require any resources associated with it.This is meant to be called from
ucxx::Future::notify().- Parameters:
future – [in] future to notify.
status – [in] the request completion status.
- virtual RequestNotifierWaitState waitRequestNotifier(
- uint64_t period
Wait for a new event with a timeout in nanoseconds.
Block while waiting for an event (new future to be notified or stop signal) with added timeout in nanoseconds to unblock after a that period if no event has occurred. A period of zero means this call will never unblock until an event occurs.
Warning
Be cautious using a period of zero, if no event ever occurs it will be impossible to continue the thread.
- Parameters:
period – [in] the time in nanoseconds to wait for an event before unblocking.
- virtual void runRequestNotifier(
Notify event loop of all pending completed futures.
This method will notify the internal resource of all pending completed futures. Notifying the resource may require some exclusion mechanism, thus it should not run indefinitely, but instead run periodically. Futures that completed must first be scheduled with
scheduleFutureNotify().
- virtual void stopRequestNotifierThread(
Make known to the notifier thread that it should stop.
Often called when the application is shutting down, make known to the notifier that it should stop and exit.
- virtual bool isRunning(
Returns whether the thread is running.
- Returns:
Whether the thread is running.