4#include "../FoundationBase.h"
5#include "../Platform/Atomic.h"
7#include <OsoMemoryProfiler/CogsMemoryProfile.h>
19#if defined(_M_X64) || defined(__amd64__)
50 virtual void * allocate(
size_t size,
size_t alignment = 0, MemBlockType type = MemBlockType::Block);
60 virtual void deallocate(
void * ptr,
size_t size, MemBlockType type = MemBlockType::Block);
62 virtual void changeType(
void* ptr,
size_t size, MemBlockType oldType, MemBlockType newType);
85 void * memory = allocator->
allocate(
sizeof(
T),
alignof(
T));
87 return new (memory)
T();
100 template<
typename T,
typename... Args>
103 void * memory = allocator->
allocate(
sizeof(
T),
alignof(
T));
105 return new (memory)
T(std::forward<Args>(args)...);
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Base allocator implementation.
Definition: Allocator.h:30
virtual ~Allocator()=default
virtual size_t getAllocatedBytes() const
Return the number of bytes currently allocated by this allocator.
Definition: Allocator.h:65
virtual void deallocate(void *ptr, size_t size, MemBlockType type=MemBlockType::Block)
Deallocate the memory block at the given pointer, with the given size.
Definition: Allocator.cpp:58
virtual void * allocate(size_t size, size_t alignment=0, MemBlockType type=MemBlockType::Block)
Allocate raw memory.
Definition: Allocator.cpp:29
virtual size_t getAllocationCount() const
Return the number of allocations currently allocated by this allocator.
Definition: Allocator.h:68
T * create(Allocator *allocator)
Allocate storage and construct an object of the type T with the given allocator.
Definition: Allocator.h:83
void destroy(T *t, Allocator *allocator)
Destroy the given object and free the allocated memory using the given allocator.
Definition: Allocator.h:117
constexpr size_t kDefaultAlignment
Definition: Allocator.h:22
Main Cogs namespace.
Definition: MortonCode.h:5
std::atomic< T > Atomic
Definition: Atomic.h:107