|
HAMR
The Heterogeneous Accelerator Memory Resource
|
a deleter for memory managed from within Python More...
#include <hamr_python_deleter.h>
Public Member Functions | |
| python_deleter (T *ptr, size_t n_elem, PyObject *obj) | |
| void | operator() (T *ptr) |
a deleter for memory managed from within Python
This class manages an array allocated by a Python code. In the functor's constructor a refrence to a user provdied Python object is stolen. When the functor is invoked, a reference to this Python object is released. It is up to the Python object to free the memory. One may use a PyCapsule to implement custom delete methods if they are needed.
| hamr::python_deleter< T >::python_deleter | ( | T * | ptr, |
| size_t | n_elem, | ||
| PyObject * | obj | ||
| ) |
constructs the deleter. A reference to obj is stolen by this constructor.
| [in] | ptr | a pointer to shared data |
| [in] | n_elem | the number of elements of type T shared |
| [in] | obj | a PyObject who's reference count will be decremented when the data shared from Python is no longer needed. |
| void hamr::python_deleter< T >::operator() | ( | T * | ptr | ) |
deletes the array
| [in] | ptr | the pointer to the array to delete. must be the same as that passed during construction. |