Program Listing for File MonotonicAllocator.h

Return to documentation for file (Source\Common\Inc\Memory\MonotonicAllocator.h)

#pragma once

#include "Allocator.h"
#include "Types.h"

namespace Azura {
namespace Memory {
class MemoryBuffer;

class MonotonicAllocator final : public Allocator {
 public:
  MonotonicAllocator(MemoryBuffer& buffer, U32 size);
  ~MonotonicAllocator() override;

  MonotonicAllocator(const MonotonicAllocator& other) = delete;
  MonotonicAllocator& operator=(const MonotonicAllocator& other) = delete;

  MonotonicAllocator(MonotonicAllocator&& other) noexcept = default;
  MonotonicAllocator& operator=(MonotonicAllocator&& other) noexcept = delete;

#ifdef BUILD_UNIT_TEST
  AddressPtr GetCurrentPtr() const {
    return m_headPtr;
  };
#endif

  void Reset() override;

 protected:
  void* Allocate(U32 size, U32 alignment) override;

  void Deallocate(void* address) override;

 private:
  AddressPtr m_headPtr;
  MemoryBuffer& m_sourceBuffer;
};
}  // namespace Memory
}  // namespace Azura