AuroraRuntime/Source/Memory/AuHeapAdapter.hpp

60 lines
1.8 KiB
C++
Raw Normal View History

/***
Copyright (C) 2021-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuHeapAdapter.hpp
File: Heap.hpp
Date: 2024-7-17
Author: Reece
***/
#pragma once
#include "AuMemory.hpp"
#include "AuBaseHeap.hpp"
#include "o1heap.hpp"
namespace Aurora::Memory
{
struct ImplHeapAdapter :
Heap,
AuEnableSharedFromThis<ImplHeapAdapter>
{
virtual AuSPtr<Heap> AllocateDivision(AuUInt32 heap, AuUInt32 alignment) override;
ImplHeapAdapter();
ImplHeapAdapter(const HeapAdapterInterface &heapInterface);
virtual ~ImplHeapAdapter();
bool Init(const HeapAdapterInterface &heapInterface);
Types::size_t GetChunkSize(const void *head) override;
void *_FAlloc(Types::size_t uLength) override;
void *_FAlloc(Types::size_t uLength, Types::size_t uAlign) override;
void *_ZAlloc(Types::size_t uLength) override;
void *_ZAlloc(Types::size_t uLength, Types::size_t uAlign) override;
void *_ZRealloc(void *pBuffer, Types::size_t uLength) override;
void *_ZRealloc(void *pBuffer, Types::size_t uLength, Types::size_t uAlign) override;
void *_FRealloc(void *pBuffer, Types::size_t uLength) override;
void *_FRealloc(void *pBuffer, Types::size_t uLength, Types::size_t uAlign) override;
void _Free(void *pBuffer) override;
AuSPtr<Heap> GetSelfReference() override;
Heap *GetSelfReferenceRaw() override;
void TryRelease();
void RequestTermination();
void WalkHeap(bool(*fCallback)(void *, void *), void *pSecondArg) override;
HeapStats &GetStats() override;
private:
HeapStats stats;
HeapAdapterInterface adapter;
protected:
bool bOwnsMemory_ {};
bool bIsDangling_ {};
};
}