ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Methods | Protected Fields | List of all members
RecyclerPSBase< TSidiNode, TList > Struct Template Reference
Collaboration diagram for RecyclerPSBase< TSidiNode, TList >:
[legend]

Class Description

template<typename TSidiNode, typename TList>
struct aworx::lib::monomem::detail::RecyclerPSBase< TSidiNode, TList >


This struct is used for recycling of "node elements" which are derived of type detail::SidiNodeBase. This class provides the common base for detail::RecyclerPrivate and detail::RecyclerShared.

Template Parameters
TSidiNodeThe type to recycle. Has to be derived of detail::SidiNodeBase.
TListThe type of the list of recyclables: Either the same as TSidiNode or a reference to it.

Definition at line 59 of file recycler.inl.

Public Methods

 RecyclerPSBase ()=default
 
 RecyclerPSBase (TList sharedRecyclables)
 
integer count () const
 
TSidiNode * get ()
 
void recycle (TSidiNode *elem)
 
void recycle (TSidiNode *first, TSidiNode *last)
 
template<typename TChunk >
void recycleChunk (TChunk *chunk, size_t count)
 

Protected Fields

TList recyclables
 

Constructor & Destructor Documentation

◆ RecyclerPSBase() [1/2]

RecyclerPSBase ( )
default

Empty constructor, used by derived type detail::RecyclerPrivate.

◆ RecyclerPSBase() [2/2]

RecyclerPSBase ( TList  sharedRecyclables)
inline

Empty constructor, used by derived type detail::RecyclerShared.

Parameters
sharedRecyclablesThe external list of recyclables.

Definition at line 73 of file recycler.inl.

Member Function Documentation

◆ count()

integer count ( ) const
inline

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

Returns
The number of available elements.

Definition at line 164 of file recycler.inl.

◆ get()

TSidiNode* get ( )
inline

Returns a stored element. If no elements are available, nullptr is returned.

Returns
A recycled element or nullptr if no recyclables are available.

Definition at line 156 of file recycler.inl.

◆ recycle() [1/2]

void recycle ( TSidiNode *  elem)
inline

Stores an element for recycling.

Parameters
elemThe element to store.

Definition at line 79 of file recycler.inl.

◆ recycle() [2/2]

void recycle ( TSidiNode *  first,
TSidiNode *  last 
)
inline

Stores a list of elements for recycling.

Parameters
firstThe first element of the list store.
lastThe last element of the list store.

Definition at line 87 of file recycler.inl.

◆ recycleChunk()

void recycleChunk ( TChunk *  chunk,
size_t  count 
)
inline

Recycles a chunk of memory that is not of the node type. Such recycling is useful for example, in combination with hash tables, which usually allocate a "bucket array" that grows over time. In this case, the former smaller bucket array may be passed to this method to recycle it as future node elements.

Template Parameters
TChunkThe type of the chunk.
Parameters
chunkThe recyclable chunk's address.
countThe number of objects (1 for non-array types, >1 for arrays.

Definition at line 100 of file recycler.inl.

Member Data Documentation

◆ recyclables

TList recyclables
protected

The list of recyclables.

Definition at line 63 of file recycler.inl.


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