Loading...
Searching...
No Matches
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
18namespace ucxx {
19
20namespace python {
21
28class 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 friend std::shared_ptr<::ucxx::Future> createFuture(std::shared_ptr<::ucxx::Notifier> notifier);
68
83 friend std::shared_ptr<::ucxx::Future> createFutureWithEventLoop(
84 PyObject* asyncioEventLoop, std::shared_ptr<::ucxx::Notifier> notifier);
85
91 virtual ~Future();
92
103 void notify(ucs_status_t status);
104
114 void set(ucs_status_t status);
115
130 [[nodiscard]] void* getHandle();
131
143 [[nodiscard]] void* release();
144};
145
146} // namespace python
147
148} // namespace ucxx
Represent a future that may be notified by a specialized notifier.
Definition future.h:21
friend std::shared_ptr<::ucxx::Future > createFutureWithEventLoop(PyObject *asyncioEventLoop, std::shared_ptr<::ucxx::Notifier > notifier)
Constructor of shared_ptr<ucxx::python::Future>.
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.
void * release()
Get the underlying PyObject* handle and release ownership.
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:16