template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
class alb::v_100::freelist_base< Shared, Allocator, MinSize, MaxSize, PoolSize, NumberOfBatchAllocations >
The FreeListBase allocator is a generic implementation of a free list pool Users shall use the alb::freelist or the alb::shared_freelist. This class serves a pool of memory blocks and holds them in a list of free blocks Each block's MinSize and MaxSize define the area of blocks sizes that are handled with this allocator. It held until PoolSize blocks. More requested deallocations a forwarded to the Allocator for deallocation. NumberOfBatchAllocations specifies how blocks are allocated by the Allocator. MinSize and MaxSize can be set at runtime by instantiating this with ALB::DynasticDynamicSet. Except the moment of instantiation, this allocator is thread safe and all operations are lock free.
- Template Parameters
-
Shared | Set to true, for a multi threaded usage, otherwise to false |
Allocator | Then allocator that should be used, when a new resource is needed |
Definition at line 47 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Constructs a FreeListBase with the specified bounding edges This c'tor is just available if the template parameter MinSize and MaxSize are set to DynasticDynamicSet. (Otherwise the compiler will tell ;-)
- Parameters
-
minSize | The lower boundary accepted by this Allocator |
maxSize | The upper boundary accepted by this Allocator |
Definition at line 80 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Frees all resources. Beware of using allocated blocks given by this allocator after calling this.
Definition at line 89 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Provides a block. If it is available in the pool, then this will be reused. If the pool is empty, then a new block will be created and returned. The passed size n must be within the boundary of the allocator, otherwise an empty block will returned. Depending on the parameter NumberOfBatchAllocations not only one new block is allocated, but as many as specified.
- Parameters
-
n | The number of requested bytes. The result is aligned to the upper boundary. |
- Returns
- The allocated block
Definition at line 141 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Appends the block to the free list if it is not filled up. The given block is reset
- Parameters
-
Definition at line 222 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
size_t alb::v_100::freelist_base< Shared, Allocator, MinSize, MaxSize, PoolSize, NumberOfBatchAllocations >::max_size |
( |
| ) |
const |
|
inlinenoexcept |
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
size_t alb::v_100::freelist_base< Shared, Allocator, MinSize, MaxSize, PoolSize, NumberOfBatchAllocations >::min_size |
( |
| ) |
const |
|
inlinenoexcept |
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Checks the ownership of the given block
- Parameters
-
- Returns
- True, it is owned by this allocator
Definition at line 213 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
Reallocates the given block. In this case only trivial case can lead to a positive result. In general reallocation to a different size > 0 is not supported by this allocator.
- Parameters
-
b | The block to reallocate |
n | The new size |
- Returns
- True, if the reallocation was successful.
Definition at line 201 of file freelist.hpp.
template<bool Shared, class Allocator, size_t MinSize, size_t MaxSize, unsigned PoolSize, unsigned NumberOfBatchAllocations>
void alb::v_100::freelist_base< Shared, Allocator, MinSize, MaxSize, PoolSize, NumberOfBatchAllocations >::set_min_max |
( |
size_t |
minSize, |
|
|
size_t |
maxSize |
|
) |
| |
|
inlinenoexcept |
Set the min and max boundary of this allocator. This method is just available if the template parameter MinSize and MaxSize are set to DynasticDynamicSet. (Otherwise the compiler will tell ;-)
- Parameters
-
minSize | The lower boundary accepted by this Allocator |
maxSize | The upper boundary accepted by this Allocator |
Definition at line 105 of file freelist.hpp.