Loading...
Searching...
No Matches
python_future_task_collector.h
1
5#pragma once
6
7#include <mutex>
8#include <vector>
9
10#include <Python.h>
11
12namespace ucxx {
13
14namespace python {
15
26class PythonFutureTaskCollector {
27 public:
28 std::vector<PyObject*> _toCollect{};
29 std::mutex _mutex{};
30
37 [[nodiscard]] static PythonFutureTaskCollector& get();
38
44 void push(PyObject* handle);
45
56 void collect();
57
58 private:
64 PythonFutureTaskCollector();
65
66 public:
67 PythonFutureTaskCollector(const PythonFutureTaskCollector&) = delete;
68 PythonFutureTaskCollector& operator=(PythonFutureTaskCollector const&) = delete;
69 PythonFutureTaskCollector(PythonFutureTaskCollector&& o) = delete;
70 PythonFutureTaskCollector& operator=(PythonFutureTaskCollector&& o) = delete;
71
78};
79
80} // namespace python
81
82} // namespace ucxx
std::mutex _mutex
Mutex to provide safe access to _toCollect.
Definition python_future_task_collector.h:29
std::vector< PyObject * > _toCollect
Tasks to be collected.
Definition python_future_task_collector.h:28
static PythonFutureTaskCollector & get()
Definition address.h:16