Nebula
Loading...
Searching...
No Matches
Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES > Class Template Reference

#include <idallocator.h>

Detailed Description

template<int MAX_ALLOCS, class... TYPES>
class Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >
See also
Ids::IdAllocator

Inherits Util::ArrayAllocatorSafe< MAX_ALLOCS, TYPES... >.

Public Member Functions

 IdAllocatorSafe ()
 constructor
Ids::Id32 Alloc ()
 Allocate an object.
void Dealloc (Ids::Id32 index)
 Deallocate an object. Just places it in freeids array for recycling.
Public Member Functions inherited from Util::ArrayAllocatorSafe< MAX_ALLOCS, TYPES... >
 ArrayAllocatorSafe ()
 constructor
 ~ArrayAllocatorSafe ()
 destructor
void operator= (const ArrayAllocatorSafe< MAX_ALLOCS, TYPES... > &rhs)
 assign operator
uint32_t Alloc ()
 allocate a new resource
void EraseIndex (const uint32_t id)
 Erase element for each.
void EraseIndexSwap (const uint32_t id)
 Erase element for each.
tuple_array_t< MEMBER, TYPES... > & Get (const uint32_t index)
 get single item from resource
const tuple_array_t< MEMBER, TYPES... > & ConstGet (const uint32_t index) const
 Get const explicitly.
void Set (const uint32_t index, const tuple_array_t< MEMBER, TYPES... > &type)
 set single item
const Util::Array< tuple_array_t< MEMBER, TYPES... > > & GetArray () const
 get array const reference
const uint32_t Size () const
 get number of used indices
void Reserve (uint32_t size)
 grow capacity of arrays to size
void Clear ()
 clear entire allocator and start from scratch.
void UpdateSize ()
 Any reserve and direct array access might mess with the size.
void TryAcquire (const uint32_t index)
 Spinlock to acquire.
bool Acquire (const uint32_t index)
 Acquire element, asserts if false and returns true if this call acquired.
void Release (const uint32_t index)
 Release an object, the next thread that acquires may use this instance as it fits.

Private Attributes

Util::Array< Ids::Id32freeIds
Util::Array< Ids::Id8generations

Additional Inherited Members

Protected Attributes inherited from Util::ArrayAllocatorSafe< MAX_ALLOCS, TYPES... >
uint32_t size
std::tuple< Util::PinnedArray< MAX_ALLOCS, TYPES >... > objects
Util::PinnedArray< MAX_ALLOCS, Threading::ThreadIdowners
Threading::Spinlock allocationLock

Constructor & Destructor Documentation

◆ IdAllocatorSafe()

template<int MAX_ALLOCS, class... TYPES>
Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::IdAllocatorSafe ( )
inline

constructor

Member Function Documentation

◆ Alloc()

template<int MAX_ALLOCS, class... TYPES>
Ids::Id32 Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Alloc ( )
inline

Allocate an object.

Note
This purposefully hides the default allocation method and should definitely not be virtual!

◆ Dealloc()

template<int MAX_ALLOCS, class... TYPES>
void Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Dealloc ( Ids::Id32 index)
inline

Deallocate an object. Just places it in freeids array for recycling.

Member Data Documentation

◆ freeIds

template<int MAX_ALLOCS, class... TYPES>
Util::Array<Ids::Id32> Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::freeIds
private

◆ generations

template<int MAX_ALLOCS, class... TYPES>
Util::Array<Ids::Id8> Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::generations
private

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