Sierra Toolkit Version of the Day
kNodeSize = nodeSize,
kNodeCount = nodeCount,
kNodesSize = nodeCount * nodeSize,
kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
kNodeAlignment = nodeAlignment,
kNodeAlignmentOffset = nodeAlignmentOffset
< Allocator >, fixed_pool >
< nodeSize, nodeCount,
bEnableOverflow, Allocator >
|fixed_node_allocator (void *pNodeBuffer)|
|fixed_node_allocator (const this_type &x)|
|this_type &||operator= (const this_type &x)|
|void *||allocate (size_t n, int=0)|
|void *||allocate (size_t n, size_t, size_t, int=0)|
|void||deallocate (void *p, size_t)|
|bool||can_allocate () const|
|void||reset (void *pNodeBuffer)|
|const char *||get_name () const|
|void||set_name (const char *pName)|
|overflow_allocator_type &||get_overflow_allocator ()|
|void||set_overflow_allocator (const overflow_allocator_type &allocator)|
Note: This class was previously named fixed_node_pool, but was changed because this name was inconsistent with the other allocators here which ended with _allocator.
Implements a fixed_pool with a given node count, alignment, and alignment offset. fixed_node_allocator is like fixed_pool except it is templated on the node type instead of being a generic allocator. All it does is pass allocations through to the fixed_pool base. This functionality is separate from fixed_pool because there are other uses for fixed_pool.
We template on kNodeSize instead of node_type because the former allows for the two different node_types of the same size to use the same template implementation.
Template parameters: nodeSize The size of the object to allocate. nodeCount The number of objects the pool contains. nodeAlignment The alignment of the objects to allocate. nodeAlignmentOffset The alignment offset of the objects to allocate. bEnableOverflow Whether or not we should use the overflow heap if our object pool is exhausted. Allocator Overflow allocator, which is only used if bEnableOverflow == true. Defaults to the global heap.
|eastl::fixed_node_allocator< nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, Allocator >::fixed_node_allocator||(||const this_type &||x||)||
Note that we are copying x.mpHead to our own fixed_pool. This at first may seem broken, as fixed pools cannot take over ownership of other fixed pools' memory. However, we declare that this copy ctor can only ever be safely called when the user has intentionally pre-seeded the source with the destination pointer. This is somewhat playing with fire, but it allows us to get around chicken-and-egg problems with containers being their own allocators, without incurring any memory costs or extra code costs. There's another reason for this: we very strongly want to avoid full copying of instances of fixed_pool around, especially via the stack. Larger pools won't even be able to fit on many machine's stacks. So this solution is also a mechanism to prevent that situation from existing and being used. Perhaps some day we'll find a more elegant yet costless way around this.
|bool eastl::fixed_node_allocator< nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, Allocator >::can_allocate||(||)|| const
|void eastl::fixed_node_allocator< nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, Allocator >::reset||(||void *||pNodeBuffer||)||