alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::onHost::internal::ManagedDealloc Struct Reference

Manage the deallocation of memory. More...

#include <ManagedDealloc.hpp>

Inheritance diagram for alpaka::onHost::internal::ManagedDealloc:

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< ManagedDeallocgetSharedPtr ()

Private Attributes

std::mutex actionGuard
std::vector< std::function< void()> > actions
std::function< void()> freeOp

Detailed Description

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.

Constructor & Destructor Documentation

◆ ManagedDealloc()

alpaka::onHost::internal::ManagedDealloc::ManagedDealloc ( std::function< void()> freeOp)
inline

Constructor.

Parameters
freeOpFunction 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.

◆ ~ManagedDealloc()

alpaka::onHost::internal::ManagedDealloc::~ManagedDealloc ( )
inline

Definition at line 32 of file ManagedDealloc.hpp.

Member Function Documentation

◆ addAction()

void alpaka::onHost::internal::ManagedDealloc::addAction ( std::function< void()> action)
inline

Add an action to be executed when the shared_ptr is destroyed.

Parameters
actionCallable to execute on destruction.

Definition at line 46 of file ManagedDealloc.hpp.

◆ getSharedPtr()

std::shared_ptr< ManagedDealloc > alpaka::onHost::internal::ManagedDealloc::getSharedPtr ( )
inline

Definition at line 52 of file ManagedDealloc.hpp.

Member Data Documentation

◆ actionGuard

std::mutex alpaka::onHost::internal::ManagedDealloc::actionGuard
private

Definition at line 59 of file ManagedDealloc.hpp.

◆ actions

std::vector<std::function<void()> > alpaka::onHost::internal::ManagedDealloc::actions
private

Definition at line 60 of file ManagedDealloc.hpp.

◆ freeOp

std::function<void()> alpaka::onHost::internal::ManagedDealloc::freeOp
private

Definition at line 58 of file ManagedDealloc.hpp.


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