ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
RecyclerPrivate< TAllocator, TNode > Struct Template Reference

Description:

template<typename TAllocator, typename TNode>
struct alib::containers::detail::RecyclerPrivate< TAllocator, TNode >

Implements internal recycling interface. Used by container types of module ALib Containers that use private recycling (when their template parameter TRecycling evaluates to Private).

Template Parameters
TAllocatorThe allocator to store and use.
TNodeThe type to recycle. Has to be derived of lang::SidiNodeBase.

Definition at line 240 of file recycler.hpp.

#include <recycler.hpp>

Inheritance diagram for RecyclerPrivate< TAllocator, TNode >:
[legend]
Collaboration diagram for RecyclerPrivate< TAllocator, TNode >:
[legend]

Public Static Method Index:

static constexpr bool IsRecycling () noexcept
 

Public Method Index:

 RecyclerPrivate () noexcept=default
 Parameterless constructor. Used with type HeapAllocator.
 
 RecyclerPrivate (const RecyclerPrivate &copy) noexcept
 
 RecyclerPrivate (RecyclerPrivate &&move) noexcept
 
 RecyclerPrivate (TAllocator &pAllocator) noexcept
 
 ~RecyclerPrivate () noexcept
 Destructor. Frees all recyclables with the allocator.
 
lang::AllocatorInterface< TAllocator > AI () const noexcept
 
integer Count () const noexcept
 
template<typename TChunk >
void DisposeChunk (TChunk *chunk, size_t length) noexcept
 
void DisposeList (TNode *begin) noexcept
 
void DisposeList (TNode *begin, TNode *end) noexcept
 
TNode * Get ()
 
TAllocator & GetAllocator () const noexcept
 
void Recycle (TNode *elem) noexcept
 
template<typename TChunk >
void RecycleChunk (TChunk *chunk, size_t length) noexcept
 
void RecycleList (TNode *begin) noexcept
 
std::pair< TNode *, integerRecycleList (TNode *begin, TNode *end) noexcept
 
void Reserve (integer qty) noexcept
 
void Reset () noexcept
 Resets this recycler. Frees all recyclables with the allocator.
 
- Public Method Index: inherited from AllocatorMember< TAllocator >
 AllocatorMember ()=delete
 Deleted default constructor. (The allocator has to be given with construction)
 
 AllocatorMember (TAllocator &pAllocator) noexcept
 
AllocatorInterface< TAllocator > AI () const noexcept
 
TAllocator & GetAllocator () const noexcept
 

Protected Type Index:

using base = lang::AllocatorMember<TAllocator>
 The base type.
 

Protected Field Index:

lang::SidiListHook< TNode > recyclables
 The list of recyclables.
 
- Protected Field Index: inherited from AllocatorMember< TAllocator >
TAllocator & allocator
 A reference to the allocator.
 

Additional Inherited Members

- Public Type Index: inherited from AllocatorMember< TAllocator >
using AllocatorType = TAllocator
 Exposes the allocator type.
 

Type Definition Details:

◆ base

template<typename TAllocator , typename TNode >
using base = lang::AllocatorMember<TAllocator>
protected

The base type.

Definition at line 244 of file recycler.hpp.

Field Details:

◆ recyclables

template<typename TAllocator , typename TNode >
lang::SidiListHook<TNode> recyclables
protected

The list of recyclables.

Definition at line 247 of file recycler.hpp.

Constructor(s) / Destructor Details:

◆ RecyclerPrivate() [1/3]

template<typename TAllocator , typename TNode >
RecyclerPrivate ( TAllocator & pAllocator)
inlineexplicitnoexcept

Constructor taking an allocator.

Parameters
pAllocatorThe allocator to use.

Definition at line 256 of file recycler.hpp.

◆ RecyclerPrivate() [2/3]

template<typename TAllocator , typename TNode >
RecyclerPrivate ( const RecyclerPrivate< TAllocator, TNode > & copy)
inlinenoexcept

Copy constructor. Does not copy the recycle node, but clears this one.

Parameters
copyThe object to copy.

Definition at line 261 of file recycler.hpp.

◆ RecyclerPrivate() [3/3]

template<typename TAllocator , typename TNode >
RecyclerPrivate ( RecyclerPrivate< TAllocator, TNode > && move)
inlinenoexcept

Move constructor. Grabs the recyclables from the moved one and sets moved to nulled.

Parameters
moveThe private recycler to move.

Definition at line 266 of file recycler.hpp.

Here is the call graph for this function:

◆ ~RecyclerPrivate()

template<typename TAllocator , typename TNode >
~RecyclerPrivate ( )
inlinenoexcept

Destructor. Frees all recyclables with the allocator.

Definition at line 274 of file recycler.hpp.

Here is the call graph for this function:

Method Details:

◆ AI()

template<typename TAllocator , typename TNode >
lang::AllocatorInterface< TAllocator > AI ( ) const
inlinenoexcept
Returns
The allocator interface of the allocator received with construction.

Definition at line 299 of file recycler.hpp.

Here is the call graph for this function:

◆ Count()

template<typename TAllocator , typename TNode >
integer Count ( ) const
inlinenodiscardnoexcept

Counts the number of recyclables.
Attention: This method runs in linear time.

Returns
The number of available elements.

Definition at line 308 of file recycler.hpp.

Here is the call graph for this function:

◆ DisposeChunk()

template<typename TAllocator , typename TNode >
template<typename TChunk >
void DisposeChunk ( TChunk * chunk,
size_t length )
inlinenoexcept

Frees the given memory. Note that the shared recycler calls RecycleChunk with this method.

Template Parameters
TChunkThe type of array that is to be freed.
Parameters
chunkThe chunk array to convert into nodes
lengthThe length of the chunk array (pass 1 if the chunk is not an array type).

Definition at line 374 of file recycler.hpp.

Here is the call graph for this function:

◆ DisposeList() [1/2]

template<typename TAllocator , typename TNode >
void DisposeList ( TNode * begin)
inlinenoexcept

Deletes the given list. This shared recycler does not free the node, but recycles them.

Parameters
beginThe first element of the list to free.

Definition at line 341 of file recycler.hpp.

Here is the call graph for this function:

◆ DisposeList() [2/2]

template<typename TAllocator , typename TNode >
void DisposeList ( TNode * begin,
TNode * end )
inlinenoexcept

Deletes a list of elements for recycling. Both given nodes have to exist.

Parameters
beginThe first element of the list to free.
endThe first element not to be freed.

Definition at line 346 of file recycler.hpp.

Here is the call graph for this function:

◆ Get()

template<typename TAllocator , typename TNode >
TNode * Get ( )
inlinenodiscard

Returns a recycled object or allocates a new one.

Returns
A recycled or allocated element.

Definition at line 318 of file recycler.hpp.

Here is the call graph for this function:

◆ GetAllocator()

template<typename TAllocator , typename TNode >
TAllocator & GetAllocator ( ) const
inlinenoexcept
Returns
Returns the allocator received with construction.

Definition at line 296 of file recycler.hpp.

Here is the call graph for this function:

◆ IsRecycling()

template<typename TAllocator , typename TNode >
static constexpr bool IsRecycling ( )
inlinestaticconstexprnoexcept
Returns
Returns true to indicate that this is not a non-recycling version.

Definition at line 302 of file recycler.hpp.

◆ Recycle()

template<typename TAllocator , typename TNode >
void Recycle ( TNode * elem)
inlinenoexcept

Stores an element for recycling.

Parameters
elemThe element to store.

Definition at line 324 of file recycler.hpp.

Here is the call graph for this function:

◆ RecycleChunk()

template<typename TAllocator , typename TNode >
template<typename TChunk >
void RecycleChunk ( TChunk * chunk,
size_t length )
inlinenoexcept

Converts a given chunk of memory, previously allocated with the same allocator that this type uses, into recyclable node objects.
This is only done if Allocator::allowsMemSplit returns true.

Template Parameters
TChunkThe type of array that is to be cut into node elements.
Parameters
chunkThe chunk array to convert into nodes
lengthThe length of the chunk array (pass 1 if the chunk is not an array type).

Definition at line 357 of file recycler.hpp.

Here is the call graph for this function:

◆ RecycleList() [1/2]

template<typename TAllocator , typename TNode >
void RecycleList ( TNode * begin)
inlinenoexcept

Stores a list of elements for recycling (from the begin element to the last one).

Parameters
beginThe first element of the list store, must not be nullptr.

Definition at line 328 of file recycler.hpp.

Here is the call graph for this function:

◆ RecycleList() [2/2]

template<typename TAllocator , typename TNode >
std::pair< TNode *, integer > RecycleList ( TNode * begin,
TNode * end )
inlinenoexcept

Stores a list of elements for recycling. Both given nodes have to exist.

Parameters
beginThe first element of the list to recycle.
endThe first element not to be recycled.
Returns
A pair of values. The first is a pointer to the last node recycled, and the second provides the number of nodes recycled.

Definition at line 335 of file recycler.hpp.

Here is the call graph for this function:

◆ Reserve()

template<typename TAllocator , typename TNode >
void Reserve ( integer qty)
inlinenoexcept

Reserves the given number of recyclables.

Parameters
qtyThe number of new recyclables to allocate.

Definition at line 313 of file recycler.hpp.

Here is the call graph for this function:

◆ Reset()

template<typename TAllocator , typename TNode >
void Reset ( )
inlinenoexcept

Resets this recycler. Frees all recyclables with the allocator.

Definition at line 286 of file recycler.hpp.

Here is the call graph for this function:

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