All Classes Namespaces Functions Variables Typedefs Enumerations Friends
Public Member Functions | Friends | List of all members
ucxx::python::Notifier Class Reference

Specialized Python implementation of a ucxx::Notifier. More...

#include <notifier.h>

Inheritance diagram for ucxx::python::Notifier:
ucxx::Notifier

Public Member Functions

 Notifier (const Notifier &)=delete
 
Notifieroperator= (Notifier const &)=delete
 
 Notifier (Notifier &&o)=delete
 
Notifieroperator= (Notifier &&o)=delete
 
virtual ~Notifier ()
 Virtual destructor. More...
 
void scheduleFutureNotify (std::shared_ptr<::ucxx::Future > future, ucs_status_t status) override
 Schedule event loop notification of completed Python future. More...
 
RequestNotifierWaitState waitRequestNotifier (uint64_t period) override
 Wait for a new event with a timeout in nanoseconds. More...
 
void runRequestNotifier () override
 Notify event loop of all pending completed Python futures. More...
 
void stopRequestNotifierThread () override
 Make known to the notifier thread that it should stop. More...
 
bool isRunning () const override
 Returns whether the thread is running. More...
 
- Public Member Functions inherited from ucxx::Notifier
 Notifier (const Notifier &)=delete
 
Notifieroperator= (Notifier const &)=delete
 
 Notifier (Notifier &&o)=delete
 
Notifieroperator= (Notifier &&o)=delete
 
virtual void scheduleFutureNotify (std::shared_ptr< Future > future, ucs_status_t status)=0
 Schedule notification of completed future. More...
 

Friends

std::shared_ptr<::ucxx::NotifiercreateNotifier ()
 Constructor of shared_ptr<ucxx::python::Notifier>. More...
 

Detailed Description

Specialized Python implementation of a ucxx::Notifier.

Specialized Python implementation of a ucxx::Notifier, providing support for notifying Python futures.

Constructor & Destructor Documentation

◆ ~Notifier()

virtual ucxx::python::Notifier::~Notifier ( )
virtual

Virtual destructor.

Virtual destructor with empty implementation.

Reimplemented from ucxx::Notifier.

Member Function Documentation

◆ isRunning()

bool ucxx::python::Notifier::isRunning ( ) const
overridevirtual

Returns whether the thread is running.

Returns
Whether the thread is running.

Implements ucxx::Notifier.

◆ runRequestNotifier()

void ucxx::python::Notifier::runRequestNotifier ( )
overridevirtual

Notify event loop of all pending completed Python futures.

This method will notify the Python asyncio event loop of all pending completed futures. Notifying the event loop requires taking the Python GIL, thus it cannot run indefinitely but must instead run periodically. Futures that completed must first be scheduled with scheduleFutureNotify().

Implements ucxx::Notifier.

◆ scheduleFutureNotify()

void ucxx::python::Notifier::scheduleFutureNotify ( std::shared_ptr<::ucxx::Future future,
ucs_status_t  status 
)
override

Schedule event loop notification of completed Python future.

Schedule the notification of the event loop of a completed Python future, but does not notify the event loop yet, which is later done by runRequestNotifier(). Because this call does not notify the Python asyncio event loop, it does not require the GIL to execute.

This is meant to be called from ucxx::python::Future::notify().

Parameters
[in]futurePython future to notify.
[in]statusthe request completion status.

◆ stopRequestNotifierThread()

void ucxx::python::Notifier::stopRequestNotifierThread ( )
overridevirtual

Make known to the notifier thread that it should stop.

Often called when the application is shutting down, make known to the notifier thread that it should stop and exit.

Implements ucxx::Notifier.

◆ waitRequestNotifier()

RequestNotifierWaitState ucxx::python::Notifier::waitRequestNotifier ( uint64_t  period)
overridevirtual

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
[in]periodthe time in nanoseconds to wait for an event before unblocking.

Implements ucxx::Notifier.

Friends And Related Function Documentation

◆ createNotifier

std::shared_ptr<::ucxx::Notifier> createNotifier ( )
friend

Constructor of shared_ptr<ucxx::python::Notifier>.

The constructor for a shared_ptr<ucxx::python::Notifier> object. The default constructor is made private to ensure all UCXX objects are shared pointers for correct lifetime management.

The notifier should run on its own Python thread, but need to have the same asyncio event loop set as the application thread. By running a notifier on its own thread the application thread can be decoupled from the overhead of allowing the UCX worker to progress on the same thread as the application to be able to notify each future, as removing the requirement for the GIL at any time by the UCX backend.

Returns
The shared_ptr<ucxx::python::Notifier> object

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