Lumiera  0.pre.03
»edit your freedom«
ExtentFamily< T, siz > Class Template Reference

#include "vault/mem/extent-family.hpp"

Description

template<typename T, size_t siz>
class vault::mem::ExtentFamily< T, siz >

Memory manager to provide a sequence of Extents for cyclic usage.

Storage extents, once allocated, will be re-used without invoking any ctors or dtors on the objects nominally located in »slots« within the Extent.

Template Parameters
Tpayload type living in the Extent's »slots«
siznumber of »slots« per Extent
See also
ExtentFamily_test

Definition at line 80 of file extent-family.hpp.

Public Types

using iterator = lib::IterableDecorator< Extent, IdxLink >
 allow transparent iteration of Extents, with the ability to expand storage
 

Public Member Functions

 ExtentFamily (size_t initialCnt=1)
 
iterator begin ()
 iterate over all the currently active Extents
 
void dropOld (size_t cnt)
 discard oldest cnt extents
 
bool empty () const
 
iterator end ()
 
iterator last ()
 positioned to the last / latest storage extent opened More...
 
void openNew (size_t cnt=1)
 claim next cnt extents, possibly allocate. More...
 
void reserve (size_t expectedMaxExtents)
 

Classes

struct  Extent
 logical structure of a memory Extent More...
 
struct  IdxLink
 Iteration »State Core« based on Extents index position. More...
 
struct  Storage
 Entry in the Extents management datastructure. More...
 

Friends

iterator begin (ExtentFamily &exFam)
 
iterator end (ExtentFamily &exFam)
 
class ExtentDiagnostic< T, siz >
 „backdoor“ to watch internals from tests
 

Private Types

using _UniqueStoragePtr = std::unique_ptr< lib::UninitialisedStorage< T, siz > >
 
using Extents = std::vector< Storage >
 

Private Member Functions

void ___sanityCheckAllocSize (size_t addCnt)
 
Extentaccess (size_t idx) const
 
size_t activeSlotCnt () const
 
bool canAccomodate (size_t addCnt) const
 
size_t freeSlotCnt () const
 
size_t incWrap (size_t idx, size_t inc=1)
 increment index, but wrap at array end. More...
 
bool isValidPos (size_t idx) const
 
bool isWrapped () const
 
bool matchPos (size_t idx, void *address)
 
size_t slotCnt () const
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

size_t after_
 
Extents extents_
 
size_t start_
 

Static Private Attributes

static const size_t EXCESS_ALLOC {5}
 number of excess new extents to add whenever new storage is required
 

Member Function Documentation

◆ openNew()

void openNew ( size_t  cnt = 1)
inline

claim next cnt extents, possibly allocate.

Remarks
the index pos previously marked as #after_ will always become the first new storage slot.
Warning
in case of #isWrapped, #first_ will be modified and thus any existing indices may be invalidated.
Note
always allocating slightly in excess

Definition at line 232 of file extent-family.hpp.

Referenced by ExtentFamily_test::reuseUnclean(), and ExtentFamily_test::simpleUsage().

+ Here is the caller graph for this function:

◆ last()

iterator last ( )
inline

positioned to the last / latest storage extent opened

Warning
undefined behaviour when empty

Definition at line 285 of file extent-family.hpp.

◆ activeSlotCnt()

size_t activeSlotCnt ( ) const
inlineprivate
Returns
number of allocated slots actually used

Definition at line 308 of file extent-family.hpp.

◆ incWrap()

size_t incWrap ( size_t  idx,
size_t  inc = 1 
)
inlineprivate

increment index, but wrap at array end.

Remarks
using the array cyclically

Definition at line 337 of file extent-family.hpp.

+ Inheritance diagram for ExtentFamily< T, siz >:
+ Collaboration diagram for ExtentFamily< T, siz >:

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