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.
 
template<int MEMBER>
void Set (const Ids::Id32 id, const Util::tuple_array_t< MEMBER, TYPES... > &type)
 Set element.
 
void Set (const Ids::Id32 id, TYPES... values)
 Set elements.
 
template<int MEMBER>
Util::tuple_array_t< MEMBER, TYPES... > & Get (const Ids::Id32 id)
 Get element.
 
template<int MEMBER>
const Util::tuple_array_t< MEMBER, TYPES... > & ConstGet (const Ids::Id32 id) const
 Const get element.
 
Util::Queue< Id32 > & FreeIds ()
 Get the free ids list from the pool.
 
void TryAcquire (const Ids::Id32 id)
 Spinlock to acquire.
 
bool Acquire (const Ids::Id32 id)
 Acquire element, asserts if false and returns true if this call acquired.
 
void Release (const Ids::Id32 id)
 Release an object, the next thread that acquires may use this instance as it fits.
 
void Dealloc (Ids::Id32 id)
 Deallocate an object. Just places it in freeids array for recycling.
 
- Public Member Functions inherited from Util::ArrayAllocatorSafe< MAX_ALLOCS, TYPES... >
 ArrayAllocatorSafe ()
 constructor
 
 ArrayAllocatorSafe (ArrayAllocatorSafe< MAX_ALLOCS, TYPES... > &&rhs)
 move constructor
 
 ArrayAllocatorSafe (const ArrayAllocatorSafe< MAX_ALLOCS, TYPES... > &rhs)
 copy constructor
 
 ~ArrayAllocatorSafe ()
 destructor
 
void operator= (const ArrayAllocatorSafe< MAX_ALLOCS, TYPES... > &rhs)
 assign operator
 
void operator= (ArrayAllocatorSafe< MAX_ALLOCS, TYPES... > &&rhs)
 move 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... > & Get (const uint32_t index) const
 same as 32 bit get, but const
 
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
 
void Set (const uint32_t index, TYPES...)
 set for each in tuple
 
const Util::Array< tuple_array_t< MEMBER, TYPES... > > & GetArray () const
 get array const reference
 
Util::Array< tuple_array_t< MEMBER, TYPES... > > & GetArray ()
 get array
 
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

Ids::IdGenerationPool pool
 

Additional Inherited Members

- Protected Attributes inherited from Util::ArrayAllocatorSafe< MAX_ALLOCS, TYPES... >
uint32_t size
 
std::tuple< Util::PinnedArray< MAX_ALLOCS, TYPES >... > objects
 
Util::Array< 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

◆ Acquire()

template<int MAX_ALLOCS, class... TYPES>
bool Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Acquire ( const Ids::Id32 id)
inline

Acquire element, asserts if false and returns true if this call acquired.

◆ 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!

◆ ConstGet()

template<int MAX_ALLOCS, class... TYPES>
template<int MEMBER>
const Util::tuple_array_t< MEMBER, TYPES... > & Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::ConstGet ( const Ids::Id32 id) const
inline

Const get element.

◆ Dealloc()

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

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

◆ FreeIds()

template<int MAX_ALLOCS, class... TYPES>
Util::Queue< Id32 > & Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::FreeIds ( )
inline

Get the free ids list from the pool.

◆ Get()

template<int MAX_ALLOCS, class... TYPES>
template<int MEMBER>
Util::tuple_array_t< MEMBER, TYPES... > & Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Get ( const Ids::Id32 id)
inline

Get element.

◆ Release()

template<int MAX_ALLOCS, class... TYPES>
void Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Release ( const Ids::Id32 id)
inline

Release an object, the next thread that acquires may use this instance as it fits.

◆ Set() [1/2]

template<int MAX_ALLOCS, class... TYPES>
template<int MEMBER>
void Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Set ( const Ids::Id32 id,
const Util::tuple_array_t< MEMBER, TYPES... > & type )
inline

Set element.

◆ Set() [2/2]

template<int MAX_ALLOCS, class... TYPES>
void Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::Set ( const Ids::Id32 id,
TYPES... values )
inline

Set elements.

◆ TryAcquire()

template<int MAX_ALLOCS, class... TYPES>
void Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::TryAcquire ( const Ids::Id32 id)
inline

Spinlock to acquire.

Member Data Documentation

◆ pool

template<int MAX_ALLOCS, class... TYPES>
Ids::IdGenerationPool Ids::IdAllocatorSafe< MAX_ALLOCS, TYPES >::pool
private

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