All Classes Namespaces Functions Variables Typedefs Enumerations Friends
python_future.h
1 
5 #pragma once
6 
7 #include <functional>
8 #include <memory>
9 
10 #include <Python.h>
11 
12 #include <ucp/api/ucp.h>
13 
14 #include <ucxx/future.h>
15 #include <ucxx/notifier.h>
16 #include <ucxx/python/future.h>
17 
18 namespace ucxx {
19 
20 namespace python {
21 
28 class Future : public ::ucxx::Future {
29  private:
30  PyObject* _asyncioEventLoop{nullptr};
31  PyObject* _handle{nullptr};
32 
47  explicit Future(PyObject* asyncioEventLoop, std::shared_ptr<::ucxx::Notifier> notifier);
48 
49  public:
50  Future() = delete;
51  Future(const Future&) = delete;
52  Future& operator=(Future const&) = delete;
53  Future(Future&& o) = delete;
54  Future& operator=(Future&& o) = delete;
55 
67  [[nodiscard]] friend std::shared_ptr<::ucxx::Future> createFuture(
68  std::shared_ptr<::ucxx::Notifier> notifier);
69 
84  [[nodiscard]] friend std::shared_ptr<::ucxx::Future> createFutureWithEventLoop(
85  PyObject* asyncioEventLoop, std::shared_ptr<::ucxx::Notifier> notifier);
86 
92  virtual ~Future();
93 
104  void notify(ucs_status_t status);
105 
115  void set(ucs_status_t status);
116 
131  [[nodiscard]] void* getHandle();
132 
144  [[nodiscard]] void* release();
145 };
146 
147 } // namespace python
148 
149 } // namespace ucxx
Represent a future that may be notified by a specialized notifier.
Definition: future.h:21
Specialized Python implementation of a ucxx::Future.
Definition: python_future.h:28
void * release()
Get the underlying PyObject* handle and release ownership.
virtual ~Future()
Virtual destructor.
void set(ucs_status_t status)
Set the future completion status.
void notify(ucs_status_t status)
Inform the notifier thread that the future has completed.
friend std::shared_ptr<::ucxx::Future > createFutureWithEventLoop(PyObject *asyncioEventLoop, std::shared_ptr<::ucxx::Notifier > notifier)
Constructor of shared_ptr<ucxx::python::Future>.
void * getHandle()
Get the underlying PyObject* handle but does not release ownership.
friend std::shared_ptr<::ucxx::Future > createFuture(std::shared_ptr<::ucxx::Notifier > notifier)
Constructor of shared_ptr<ucxx::python::Future>.
Definition: address.h:15