![]() |
alpaka
Abstraction Library for Parallel Kernel Acceleration
|
Manage the deallocation of memory. More...
#include <ManagedDealloc.hpp>
Public Member Functions | |
| ManagedDealloc (std::function< void()> freeOp) | |
| Constructor. | |
| ~ManagedDealloc () | |
| void | addAction (std::function< void()> action) |
| Add an action to be executed when the shared_ptr is destroyed. | |
| std::shared_ptr< ManagedDealloc > | getSharedPtr () |
Private Attributes | |
| std::mutex | actionGuard |
| std::vector< std::function< void()> > | actions |
| std::function< void()> | freeOp |
Manage the deallocation of memory.
This class is used to manage the deallocation of memory in a shared_ptr. It takes a function that will be called when the shared_ptr is destroyed. This is useful for managing memory that needs to be deallocated when the shared_ptr goes out of scope.
Definition at line 21 of file ManagedDealloc.hpp.
|
inline |
Constructor.
| freeOp | Function to be called when the shared_ptr is destroyed after all actions are executed. All dependencies required to deallocate the memory must be holed by freeOp. |
Definition at line 28 of file ManagedDealloc.hpp.
|
inline |
Definition at line 32 of file ManagedDealloc.hpp.
|
inline |
Add an action to be executed when the shared_ptr is destroyed.
| action | Callable to execute on destruction. |
Definition at line 46 of file ManagedDealloc.hpp.
|
inline |
Definition at line 52 of file ManagedDealloc.hpp.
|
private |
Definition at line 59 of file ManagedDealloc.hpp.
|
private |
Definition at line 60 of file ManagedDealloc.hpp.
|
private |
Definition at line 58 of file ManagedDealloc.hpp.