Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::static_pool_concurrent_allocator< Node, NumNodes > Class Template Reference

#include <allocator_concurrent_static.h>

Public Types

using value_type = Node
 
using pointer = Node *
 
using size_type = AZStd::size_t
 
using difference_type = AZStd::ptrdiff_t
 

Public Member Functions

AZ_FORCE_INLINE static_pool_concurrent_allocator (const char *name="AZStd::static_pool_concurrent_allocator")
 
AZ_FORCE_INLINE static_pool_concurrent_allocator (const this_type &rhs)
 
AZ_FORCE_INLINE static_pool_concurrent_allocator (const this_type &rhs, const char *name)
 
AZ_FORCE_INLINE this_typeoperator= (const this_type &rhs)
 
AZ_FORCE_INLINE const char * get_name () const
 
AZ_FORCE_INLINE void set_name (const char *name)
 
constexpr size_type max_size () const
 
AZ_FORCE_INLINE size_type get_allocated_size () const
 
Node * allocate ()
 
pointer allocate (size_type byteSize, size_type alignment, int flags=0)
 
void deallocate (Node *ptr)
 
void deallocate (pointer ptr, size_type byteSize, size_type alignment)
 
AZ_FORCE_INLINE size_type resize (pointer ptr, size_type newSize)
 
void reset ()
 
void leak_before_destroy ()
 
AZ_FORCE_INLINE void * data () const
 
AZ_FORCE_INLINE constexpr size_type data_size () const
 

Detailed Description

template<class Node, AZStd::size_t NumNodes>
class AZStd::static_pool_concurrent_allocator< Node, NumNodes >

Declares a static buffer of Node[NumNodes], and them pools them. It provides concurrent safe access. This is a perfect allocator for pooling lists or hash table nodes. Internally the buffer is allocated using aligned_storage.

Note
only allocate/deallocate are thread safe. reset, leak_before_destroy and comparison operators are not thread safe. get_allocated_size is thread safe but the returned value is not perfectly in sync on the actual number of allocations (the number of allocations is incremented before the allocation happens and decremented after the allocation happens, trying to give a conservative number)
be careful if you use this on the stack, since many platforms do NOT support alignment more than 16 bytes. In such cases you will need to do it manually.

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