Hedgehog
3.1.0
A library to generate hybrid pipeline workflow systems
|
Static memory manager. More...
#include "static_memory_manager.h"
Public Member Functions | |
StaticMemoryManager (size_t const &capacity, Args ... args) | |
Constructor to a static memory manager. | |
StaticMemoryManager (StaticMemoryManager< T, Args... > const &rhs) | |
Copy constructor. | |
~StaticMemoryManager () override=default | |
Default destructor. | |
std::shared_ptr< ManagedMemory > | getManagedMemory () final |
Get a managed memory from the pool. | |
std::shared_ptr< AbstractMemoryManager > | copy () override |
Default copy method. | |
virtual void | initializeMemoryManager () |
User-definable initialization step for a memory manager. | |
![]() | |
AbstractMemoryManager (size_t const &capacity) | |
Only used constructor. | |
virtual | ~AbstractMemoryManager ()=default |
Default destructor. | |
int | deviceId () const |
Device Id accessor. | |
size_t | currentSize () |
Return the current size of the inside pool. | |
size_t | capacity () const |
Capacity accessor. | |
void | deviceId (int deviceId) |
Device id setter. | |
void | profiler (const std::shared_ptr< NvtxProfiler > &profiler) |
NVTX profiler setter. | |
virtual std::shared_ptr< ManagedMemory > | getManagedMemory ()=0 |
Get an available managed memory, block if none are available. | |
virtual void | recycleMemory (std::shared_ptr< ManagedMemory > const &managedMemory)=0 |
Recycle memory. | |
virtual std::shared_ptr< AbstractMemoryManager > | copy ()=0 |
Virtual copy method used for task duplication and execution pipeline. | |
virtual void | initialize ()=0 |
Initialize the memory manager. | |
virtual std::string | managedType () const =0 |
Return the real managed type under the form of a string. | |
Private Member Functions | |
void | recycleMemory (std::shared_ptr< ManagedMemory > const &managedMemory) final |
Recycling mechanism for managed memory. | |
void | initialize () final |
Initialize the memory manager. | |
template<size_t... Is> | |
void | initialize (std::index_sequence< Is... >) |
Initialize implementation using the tuple of arguments stored. | |
std::string | managedType () const final |
Getter to real managed type as string. | |
Private Attributes | |
std::tuple< Args... > | args_ = {} |
Values to pass to the constructor. | |
Additional Inherited Members | |
![]() | |
std::shared_ptr< NvtxProfiler > const & | profiler () const |
Accessor to NVTX profiler. | |
std::unique_ptr< tool::Pool< ManagedMemory > > const & | pool () const |
Inside pool accessor. | |
bool | isInitialized () const |
Initialized flag accessor. | |
std::mutex & | memoryManagerMutex () |
User api mutex accessor. | |
void | initialized () |
Flag the memory manager has initialized. | |
![]() | |
std::mutex | memoryManagerMutex_ = {} |
Mutex for user interface. | |
Static memory manager.
Static Memory manager with custom created managed object. The type T managed has to present a constructor with a signature that matches exactly the template argument list Args...
T | Type managed |
Args | List of types that should match the constructor of T parameters |
Definition at line 38 of file static_memory_manager.h.
|
inlineexplicit |
Constructor to a static memory manager.
Construct a static memory manager from its capacity, and the arguments used to construct all elements in the pool.
capacity | Memory manager capacity |
args | Arguments used to construct every elements in the pool |
Definition at line 49 of file static_memory_manager.h.
|
inline |
Copy constructor.
rhs | StaticMemoryManager to construct from |
Definition at line 54 of file static_memory_manager.h.
|
overridedefault |
Default destructor.
|
inlineoverridevirtual |
Default copy method.
Implements hh::AbstractMemoryManager.
Definition at line 74 of file static_memory_manager.h.
|
inlinefinalvirtual |
Get a managed memory from the pool.
Get a managed memory from the pool. If the pool is empty, the call will block until a new element get available.
Implements hh::AbstractMemoryManager.
Definition at line 64 of file static_memory_manager.h.
|
inlinefinalprivatevirtual |
Initialize the memory manager.
Thread safe initialization, fill the pool with custom constructed object
Implements hh::AbstractMemoryManager.
Definition at line 100 of file static_memory_manager.h.
|
inlineprivate |
Initialize implementation using the tuple of arguments stored.
Is | Index of the arguments tuple |
Definition at line 113 of file static_memory_manager.h.
|
inlinevirtual |
User-definable initialization step for a memory manager.
Definition at line 79 of file static_memory_manager.h.
|
inlinefinalprivatevirtual |
Getter to real managed type as string.
Implements hh::AbstractMemoryManager.
Definition at line 125 of file static_memory_manager.h.
|
inlinefinalprivatevirtual |
Recycling mechanism for managed memory.
Thread safe recycle that will in sequence:
managedMemory | Type of the managed memory |
Implements hh::AbstractMemoryManager.
Definition at line 88 of file static_memory_manager.h.
|
private |
Values to pass to the constructor.
Definition at line 42 of file static_memory_manager.h.