HAMR
The Heterogeneous Accelerator Memory Resource
hamr::python_deleter< T > Class Template Reference

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)
 

Detailed Description

template<typename T>
class hamr::python_deleter< T >

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.

Constructor & Destructor Documentation

◆ python_deleter()

template<typename T >
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.

Parameters
[in]ptra pointer to shared data
[in]n_elemthe number of elements of type T shared
[in]obja PyObject who's reference count will be decremented when the data shared from Python is no longer needed.

Member Function Documentation

◆ operator()()

template<typename T >
void hamr::python_deleter< T >::operator() ( T *  ptr)

deletes the array

Parameters
[in]ptrthe pointer to the array to delete. must be the same as that passed during construction.

The documentation for this class was generated from the following file: