ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::containers::detail::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 462 of file recycling.inl.

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>& alib::containers::detail::RecyclerShared< TAllocator, TNode >::sr
protected

The reference to the list of recyclables.

Definition at line 466 of file recycling.inl.

Constructor(s) / Destructor Details:

◆ RecyclerShared() [1/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerShared< TAllocator, TNode >::RecyclerShared ( SharedRecycler< TAllocator, TNode > & hook)
inlinenoexcept

Constructor taking an allocator and the hook.

Parameters
hookThe external, shared recycling list.

Definition at line 472 of file recycling.inl.

◆ RecyclerShared() [2/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerShared< TAllocator, TNode >::RecyclerShared ( const RecyclerShared< TAllocator, TNode > & copy)
defaultnoexcept

Copy constructor. Copies the reference to the shared recycler.

Parameters
copyThe private recycler to copy.
Here is the call graph for this function:

◆ RecyclerShared() [3/3]

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerShared< TAllocator, 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 482 of file recycling.inl.

Here is the call graph for this function:

◆ ~RecyclerShared()

template<typename TAllocator, typename TNode>
alib::containers::detail::RecyclerShared< TAllocator, TNode >::~RecyclerShared ( )
inlinenoexcept

Destructor.

Definition at line 486 of file recycling.inl.

Method Details:

◆ AI()

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

Definition at line 495 of file recycling.inl.

◆ Count()

template<typename TAllocator, typename TNode>
integer alib::containers::detail::RecyclerShared< TAllocator, TNode >::Count ( ) const
inlinenodiscardnoexcept

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

Returns
The number of available elements.

Definition at line 505 of file recycling.inl.

◆ DisposeChunk()

template<typename TAllocator, typename TNode>
template<typename TChunk>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::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 563 of file recycling.inl.

Here is the call graph for this function:

◆ DisposeList() [1/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::DisposeList ( TNode * begin)
inlinenoexcept

Does not free, but recycles instead.

Parameters
beginThe first element of the list to free.

Definition at line 536 of file recycling.inl.

Here is the call graph for this function:

◆ DisposeList() [2/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::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 541 of file recycling.inl.

Here is the call graph for this function:

◆ Get()

template<typename TAllocator, typename TNode>
TNode * alib::containers::detail::RecyclerShared< TAllocator, TNode >::Get ( )
inlinenodiscard

Returns a recycled object or allocates a new one.

Returns
A recycled or allocated element.

Definition at line 514 of file recycling.inl.

◆ GetAllocator()

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

Definition at line 492 of file recycling.inl.

◆ IsRecycling()

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

Definition at line 499 of file recycling.inl.

◆ Recycle()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::Recycle ( TNode * elem)
inlinenoexcept

Stores an element for recycling.

Parameters
elemThe element to store.

Definition at line 520 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleChunk()

template<typename TAllocator, typename TNode>
template<typename TChunk>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::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 550 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleList() [1/2]

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::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 524 of file recycling.inl.

Here is the call graph for this function:

◆ RecycleList() [2/2]

template<typename TAllocator, typename TNode>
std::pair< TNode *, integer > alib::containers::detail::RecyclerShared< TAllocator, TNode >::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 531 of file recycling.inl.

Here is the call graph for this function:

◆ Reserve()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::Reserve ( integer qty)
inline

Reserves the given number of recyclables.

Parameters
qtyThe number of new recyclables to allocate.

Definition at line 509 of file recycling.inl.

Here is the call graph for this function:

◆ Reset()

template<typename TAllocator, typename TNode>
void alib::containers::detail::RecyclerShared< TAllocator, TNode >::Reset ( )
inlinenoexcept

Does nothing. Shared recyclers can't be reset.

Definition at line 489 of file recycling.inl.


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