21#ifndef HEDGEHOG_MEMORY_MANAGER_H_ 
   22#define HEDGEHOG_MEMORY_MANAGER_H_ 
   26#include "../managed_memory.h" 
   28#include "../../../tools/concepts.h" 
   36template<tool::ManageableMemory T>
 
   49  std::shared_ptr<AbstractMemoryManager> 
copy()
 override {
 
   50    return std::make_shared<MemoryManager>(this->
capacity());
 
   61    std::shared_ptr<ManagedMemory> managedMemory = 
nullptr;
 
   62    managedMemory = this->
pool()->pop_front();
 
   63    managedMemory->preProcess();
 
   74  void recycleMemory(std::shared_ptr<ManagedMemory> 
const &managedMemory) 
final {
 
   76    managedMemory->postProcess();
 
   77    if (managedMemory->canBeRecycled()) {
 
   78      this->
profiler()->addReleaseMarker();
 
   79      managedMemory->clean();
 
   80      this->
pool()->push_back(managedMemory);
 
   92          this->
pool()->begin(), this->
pool()->end(),
 
   93          [
this](std::shared_ptr<ManagedMemory> &emptyShared) {
 
   94            emptyShared = std::make_shared<T>();
 
   95            emptyShared->memoryManager(
this);
 
  105  [[nodiscard]] std::string 
managedType() const final { 
return hh::tool::typeToStr<T>(); }
 
std::mutex memoryManagerMutex_
Mutex for user interface.
std::shared_ptr< NvtxProfiler > const & profiler() const
Accessor to NVTX profiler.
bool isInitialized() const
Initialized flag accessor.
size_t capacity() const
Capacity accessor.
std::unique_ptr< tool::Pool< ManagedMemory > > const & pool() const
Inside pool accessor.
void initialized()
Flag the memory manager has initialized.
virtual void initializeMemoryManager()
User-definable initialization step for a memory manager.
std::shared_ptr< ManagedMemory > getManagedMemory() final
Get managed memory from the pool.
std::shared_ptr< AbstractMemoryManager > copy() override
Default copy method.
void recycleMemory(std::shared_ptr< ManagedMemory > const &managedMemory) final
Recycling mechanism for managed memory.
MemoryManager(size_t const &capacity)
Create a memory manager with a certain capacity.
void initialize() final
Initialize the memory manager.
~MemoryManager() override=default
Default destructor.
std::string managedType() const final
Getter to real managed type as string.