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

Description:

template<typename TAllocator, typename TNode>
class alib::containers::detail::RecyclerShared< TAllocator, TNode >

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

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

Definition at line 458 of file recycler.hpp.

#include <recycler.hpp>

Public Static Method Index:

static constexpr bool IsRecycling () noexcept
 

Public Method Index:

 RecyclerShared (const RecyclerShared &copy) noexcept=default
 
 RecyclerShared (RecyclerShared &&move) noexcept
 
 RecyclerShared (SharedRecycler< TAllocator, TNode > &hook) noexcept
 
 ~RecyclerShared () noexcept
 Destructor.
 
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)
 
void Reset () noexcept
 Does nothing. Shared recyclers can't be reset.
 

Protected Field Index:

SharedRecycler< TAllocator, TNode > & sr
 The reference to the list of recyclables.
 

Field Details:

◆ sr

template<typename TAllocator , typename TNode >
SharedRecycler<TAllocator,TNode>& sr
protected

The reference to the list of recyclables.

Definition at line 462 of file recycler.hpp.

Constructor(s) / Destructor Details:

◆ RecyclerShared() [1/3]

template<typename TAllocator , typename TNode >
RecyclerShared ( SharedRecycler< TAllocator, TNode > & hook)
inlinenoexcept

Constructor taking an allocator and the hook.

Parameters
hookThe external, shared recycling list.

Definition at line 468 of file recycler.hpp.

◆ RecyclerShared() [2/3]

template<typename TAllocator , typename TNode >
RecyclerShared ( const RecyclerShared< TAllocator, TNode > & copy)
defaultnoexcept

Copy constructor. Copies the reference to the shared recycler.

Parameters
copyThe private recycler to copy.

◆ RecyclerShared() [3/3]

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

Move constructor. Just copies the reference but leaves original intact. (We don't care)

Parameters
moveThe private recycler to move.

Definition at line 478 of file recycler.hpp.

◆ ~RecyclerShared()

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

Destructor.

Definition at line 482 of file recycler.hpp.

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 491 of file recycler.hpp.

◆ 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 501 of file recycler.hpp.

◆ DisposeChunk()

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

This 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 559 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

Does not free, but recycles instead.

Parameters
beginThe first element of the list to free.

Definition at line 532 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

Does not free, but recycles instead.

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

Definition at line 537 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 510 of file recycler.hpp.

◆ GetAllocator()

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

Definition at line 488 of file recycler.hpp.

◆ 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 495 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 516 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 546 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 520 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 527 of file recycler.hpp.

Here is the call graph for this function:

◆ Reserve()

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

Reserves the given number of recyclables.

Parameters
qtyThe number of new recyclables to allocate.

Definition at line 505 of file recycler.hpp.

Here is the call graph for this function:

◆ Reset()

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

Does nothing. Shared recyclers can't be reset.

Definition at line 485 of file recycler.hpp.


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