All Classes Namespaces Functions Variables Typedefs Enumerations Friends
notifier.h
1 
5 #pragma once
6 
7 #include <condition_variable>
8 #include <memory>
9 #include <mutex>
10 #include <utility>
11 #include <vector>
12 
13 #include <ucxx/future.h>
14 #include <ucxx/notifier.h>
15 
16 namespace ucxx {
17 
18 namespace python {
19 
26 class Notifier : public ::ucxx::Notifier {
27  private:
28  std::mutex _notifierThreadMutex{};
29  std::vector<std::pair<std::shared_ptr<::ucxx::Future>, ucs_status_t>>
30  _notifierThreadFutureStatus{};
31  bool _notifierThreadFutureStatusReady{false};
32  RequestNotifierThreadState _notifierThreadFutureStatusFinished{
33  RequestNotifierThreadState::NotRunning};
34  std::condition_variable
35  _notifierThreadConditionVariable{};
36 
43  Notifier() = default;
44 
54  [[nodiscard]] RequestNotifierWaitState waitRequestNotifierWithoutTimeout();
55 
64  [[nodiscard]] RequestNotifierWaitState waitRequestNotifierWithTimeout(uint64_t period);
65 
66  public:
67  Notifier(const Notifier&) = delete;
68  Notifier& operator=(Notifier const&) = delete;
69  Notifier(Notifier&& o) = delete;
70  Notifier& operator=(Notifier&& o) = delete;
71 
87  [[nodiscard]] friend std::shared_ptr<::ucxx::Notifier> createNotifier();
88 
94  virtual ~Notifier();
95 
109  void scheduleFutureNotify(std::shared_ptr<::ucxx::Future> future, ucs_status_t status) override;
110 
123  [[nodiscard]] RequestNotifierWaitState waitRequestNotifier(uint64_t period) override;
124 
133  void runRequestNotifier() override;
134 
141  void stopRequestNotifierThread() override;
142 
148  [[nodiscard]] bool isRunning() const override;
149 };
150 
151 } // namespace python
152 
153 } // namespace ucxx
Notifier for status of futures.
Definition: notifier.h:38
Specialized Python implementation of a ucxx::Notifier.
Definition: notifier.h:26
bool isRunning() const override
Returns whether the thread is running.
RequestNotifierWaitState waitRequestNotifier(uint64_t period) override
Wait for a new event with a timeout in nanoseconds.
void stopRequestNotifierThread() override
Make known to the notifier thread that it should stop.
void runRequestNotifier() override
Notify event loop of all pending completed Python futures.
virtual ~Notifier()
Virtual destructor.
friend std::shared_ptr<::ucxx::Notifier > createNotifier()
Constructor of shared_ptr<ucxx::python::Notifier>.
void scheduleFutureNotify(std::shared_ptr<::ucxx::Future > future, ucs_status_t status) override
Schedule event loop notification of completed Python future.
Definition: address.h:15
RequestNotifierWaitState
The state with which a wait operation completed.
Definition: notifier.h:26
RequestNotifierThreadState
The state of the notifier thread.
Definition: notifier.h:19