Cogs.Core
Public Member Functions | Private Attributes | List of all members
Cogs::Core::CoreAllocator Class Reference
Inheritance diagram for Cogs::Core::CoreAllocator:
Cogs::Memory::Allocator

Public Member Functions

 CoreAllocator (Memory::Allocator *baseAllocator, StringView tag, bool base=false)
 
size_t size () const
 
size_t count () const
 
size_t peakSize () const
 
size_t peakCount () const
 
void * allocate (size_t size, size_t alignment, MemBlockType type=MemBlockType::CoreAllocator) override
 Allocate raw memory.
 
void deallocate (void *ptr, size_t size, MemBlockType type=MemBlockType::CoreAllocator) override
 Deallocate the memory block at the given pointer, with the given size.
 
size_t getAllocatedBytes () const override
 Return the number of bytes currently allocated by this allocator.
 
size_t getAllocationCount () const override
 Return the number of allocations currently allocated by this allocator.
 
- Public Member Functions inherited from Cogs::Memory::Allocator
virtual void * allocate (size_t size, size_t alignment=0, MemBlockType type=MemBlockType::Block)
 Allocate raw memory.
 
virtual void deallocate (void *ptr, size_t size, MemBlockType type=MemBlockType::Block)
 Deallocate the memory block at the given pointer, with the given size.
 
virtual void changeType (void *ptr, size_t size, MemBlockType oldType, MemBlockType newType)
 
virtual size_t getAllocatedBytes () const
 Return the number of bytes currently allocated by this allocator.
 
virtual size_t getAllocationCount () const
 Return the number of allocations currently allocated by this allocator.
 

Private Attributes

Memory::AllocatorbaseAllocator
 
Atomic< size_t > allocationSize { 0 }
 
Atomic< size_t > allocationCount { 0 }
 
Atomic< size_t > peakAllocationSize { 0 }
 
Atomic< size_t > peakAllocationCount { 0 }
 
StringView tag
 
bool base = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Cogs::Memory::Allocator
static AllocatordefaultAllocator ()
 Gets the system default allocator.
 
static AllocatoroverflowAllocator ()
 
- Protected Attributes inherited from Cogs::Memory::Allocator
Cogs::Atomic< size_t > allocated {0}
 
Cogs::Atomic< size_t > allocations {0}
 

Detailed Description

Definition at line 17 of file MemoryContext.cpp.

Constructor & Destructor Documentation

◆ CoreAllocator()

Cogs::Core::CoreAllocator::CoreAllocator ( Memory::Allocator baseAllocator,
StringView  tag,
bool  base = false 
)
inline

Definition at line 20 of file MemoryContext.cpp.

◆ ~CoreAllocator()

Cogs::Core::CoreAllocator::~CoreAllocator ( )
inline

Definition at line 27 of file MemoryContext.cpp.

Member Function Documentation

◆ allocate()

void * Cogs::Core::CoreAllocator::allocate ( size_t  size,
size_t  alignment,
MemBlockType  type = MemBlockType::CoreAllocator 
)
inlineoverridevirtual

Allocate raw memory.

Parameters
sizeSize in bytes of requested allocation.
alignmentAlignment in bytes.
Returns
Pointer to allocated memory.

Reimplemented from Cogs::Memory::Allocator.

Definition at line 43 of file MemoryContext.cpp.

References Cogs::Memory::Allocator::allocate().

◆ count()

size_t Cogs::Core::CoreAllocator::count ( ) const
inline

Definition at line 38 of file MemoryContext.cpp.

◆ deallocate()

void Cogs::Core::CoreAllocator::deallocate ( void *  ptr,
size_t  size,
MemBlockType  type = MemBlockType::CoreAllocator 
)
inlineoverridevirtual

Deallocate the memory block at the given pointer, with the given size.

The size parameter may be given to enable extra checking when releasing memory.

Parameters
ptrPointer to previously allocated memory.
sizeSize in bytes of the given allocation.

Reimplemented from Cogs::Memory::Allocator.

Definition at line 53 of file MemoryContext.cpp.

References Cogs::Memory::Allocator::deallocate().

◆ getAllocatedBytes()

size_t Cogs::Core::CoreAllocator::getAllocatedBytes ( ) const
inlineoverridevirtual

Return the number of bytes currently allocated by this allocator.

Reimplemented from Cogs::Memory::Allocator.

Definition at line 61 of file MemoryContext.cpp.

◆ getAllocationCount()

size_t Cogs::Core::CoreAllocator::getAllocationCount ( ) const
inlineoverridevirtual

Return the number of allocations currently allocated by this allocator.

Reimplemented from Cogs::Memory::Allocator.

Definition at line 64 of file MemoryContext.cpp.

◆ peakCount()

size_t Cogs::Core::CoreAllocator::peakCount ( ) const
inline

Definition at line 41 of file MemoryContext.cpp.

◆ peakSize()

size_t Cogs::Core::CoreAllocator::peakSize ( ) const
inline

Definition at line 40 of file MemoryContext.cpp.

◆ size()

size_t Cogs::Core::CoreAllocator::size ( ) const
inline

Definition at line 37 of file MemoryContext.cpp.

Member Data Documentation

◆ allocationCount

Atomic<size_t> Cogs::Core::CoreAllocator::allocationCount { 0 }
private

Definition at line 70 of file MemoryContext.cpp.

◆ allocationSize

Atomic<size_t> Cogs::Core::CoreAllocator::allocationSize { 0 }
private

Definition at line 69 of file MemoryContext.cpp.

◆ base

bool Cogs::Core::CoreAllocator::base = false
private

Definition at line 75 of file MemoryContext.cpp.

◆ baseAllocator

Memory::Allocator* Cogs::Core::CoreAllocator::baseAllocator
private

Definition at line 67 of file MemoryContext.cpp.

◆ peakAllocationCount

Atomic<size_t> Cogs::Core::CoreAllocator::peakAllocationCount { 0 }
private

Definition at line 72 of file MemoryContext.cpp.

◆ peakAllocationSize

Atomic<size_t> Cogs::Core::CoreAllocator::peakAllocationSize { 0 }
private

Definition at line 71 of file MemoryContext.cpp.

◆ tag

StringView Cogs::Core::CoreAllocator::tag
private

Definition at line 74 of file MemoryContext.cpp.


The documentation for this class was generated from the following file: