Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
hh::ManagedMemory Class Reference

Abstraction used to manage an user type with a memory manager. More...

#include "managed_memory.h"

Inheritance diagram for hh::ManagedMemory:
Inheritance graph
Collaboration diagram for hh::ManagedMemory:
Collaboration graph

Public Member Functions

 ManagedMemory ()=default
 Default constructor.
 
virtual ~ManagedMemory ()=default
 Default destructor.
 
bool isMemoryManagerConnected ()
 Test is a memory manager has been connected to the managed memory.
 
AbstractMemoryManagermemoryManager () const
 Memory manager accessor.
 
void memoryManager (AbstractMemoryManager *memoryManager)
 Memory manager setter.
 
void returnToMemoryManager ()
 Return the data to the memory manager.
 
virtual void postProcess ()
 Mechanism called by Hedgehog when the node returns the memory before it is tested for being recycled (call to canBeRecycled)
 
virtual bool canBeRecycled ()
 Accessor to test if the data can be cleaned and sent back to the Pool, true by default.
 
virtual void clean ()
 Mechanism to clean data.
 
virtual void preProcess ()
 Mechanism to pre process the data.
 

Private Attributes

AbstractMemoryManagermemoryManager_ = nullptr
 Link to the Memory Manager.
 

Detailed Description

Abstraction used to manage an user type with a memory manager.

Definition at line 34 of file managed_memory.h.

Constructor & Destructor Documentation

◆ ManagedMemory()

hh::ManagedMemory::ManagedMemory ( )
default

Default constructor.

◆ ~ManagedMemory()

virtual hh::ManagedMemory::~ManagedMemory ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ canBeRecycled()

virtual bool hh::ManagedMemory::canBeRecycled ( )
inlinevirtual

Accessor to test if the data can be cleaned and sent back to the Pool, true by default.

Returns
True if the data can be sent to the Pool, else False

Definition at line 71 of file managed_memory.h.

◆ clean()

virtual void hh::ManagedMemory::clean ( )
inlinevirtual

Mechanism to clean data.

If the ManagedMemory type uses user-defined allocations, then clean is an appropriate place to deallocate the user-allocated data. It will be called only once before it is sent back to the pool.

Attention
If a StaticMemoryManager is used, then deallocation should be done within the destructor to match any allocations done within the constructor. (see StaticMemoryManager for more details)

Definition at line 78 of file managed_memory.h.

◆ isMemoryManagerConnected()

bool hh::ManagedMemory::isMemoryManagerConnected ( )
inline

Test is a memory manager has been connected to the managed memory.

Returns
True if a memory manager has been connected, else False

Definition at line 46 of file managed_memory.h.

◆ memoryManager() [1/2]

AbstractMemoryManager * hh::ManagedMemory::memoryManager ( ) const
inline

Memory manager accessor.

Returns
Memory manager

Definition at line 50 of file managed_memory.h.

◆ memoryManager() [2/2]

void hh::ManagedMemory::memoryManager ( AbstractMemoryManager memoryManager)
inline

Memory manager setter.

Parameters
memoryManagerMemory manager to set

Definition at line 54 of file managed_memory.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postProcess()

virtual void hh::ManagedMemory::postProcess ( )
inlinevirtual

Mechanism called by Hedgehog when the node returns the memory before it is tested for being recycled (call to canBeRecycled)

Definition at line 67 of file managed_memory.h.

◆ preProcess()

virtual void hh::ManagedMemory::preProcess ( )
inlinevirtual

Mechanism to pre process the data.

If the ManagedMemory type uses user-defined allocations such as unified memory, then preProcess is an appropriate place to apply synchronization on any asynchronous operations that were applied in the clean function. It will be called only once before it is returned from getManagedMemory.

Definition at line 84 of file managed_memory.h.

◆ returnToMemoryManager()

void hh::ManagedMemory::returnToMemoryManager ( )
inline

Return the data to the memory manager.

Exceptions
std::runtime_errorif the data is not linked to a memory manager

Definition at line 58 of file managed_memory.h.

Here is the call graph for this function:

Member Data Documentation

◆ memoryManager_

AbstractMemoryManager* hh::ManagedMemory::memoryManager_ = nullptr
private

Link to the Memory Manager.

Definition at line 36 of file managed_memory.h.