Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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 71 of file extent-family.hpp.

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...
 

Public Types

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

Public Member Functions

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

Friends

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

Private Types

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

Private Member Functions

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

Private Attributes

Extents extents_
 
size_t start_
 
size_t after_
 

Static Private Attributes

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

Constructor & Destructor Documentation

◆ ExtentFamily()

template<typename T , size_t siz>
ExtentFamily ( size_t  initialCnt = 1)
inlineexplicit

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

Member Typedef Documentation

◆ _UniqueStoragePtr

template<typename T , size_t siz>
using _UniqueStoragePtr = std::unique_ptr<lib::UninitialisedStorage<T,siz> >
private

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

◆ Extents

template<typename T , size_t siz>
using Extents = std::vector<Storage>
private

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

◆ iterator

template<typename T , size_t siz>
using iterator = lib::IterableDecorator<IdxLink>

allow transparent iteration of Extents, with the ability to expand storage

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

Member Function Documentation

◆ reserve()

template<typename T , size_t siz>
void reserve ( size_t  expectedMaxExtents)
inline

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

References ExtentFamily< T, siz >::extents_.

◆ openNew()

template<typename T , size_t siz>
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 223 of file extent-family.hpp.

References ExtentFamily< T, siz >::___sanityCheckAllocSize(), ExtentFamily< T, siz >::after_, ExtentFamily< T, siz >::canAccomodate(), ExtentFamily< T, siz >::EXCESS_ALLOC, ExtentFamily< T, siz >::extents_, ExtentFamily< T, siz >::freeSlotCnt(), ExtentFamily< T, siz >::incWrap(), ExtentFamily< T, siz >::isWrapped(), ExtentFamily< T, siz >::last(), ExtentFamily< T, siz >::slotCnt(), and ExtentFamily< T, siz >::start_.

Referenced by ExtentFamily< T, siz >::IdxLink::expandAlloc(), ExtentFamily_test::reuseUnclean(), and BlockFlow< CONF >::until().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dropOld()

template<typename T , size_t siz>
void dropOld ( size_t  cnt)
inline

discard oldest cnt extents

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

References ExtentFamily< T, siz >::activeSlotCnt(), ExtentFamily< T, siz >::incWrap(), and ExtentFamily< T, siz >::start_.

Referenced by BlockFlow< CONF >::discardBefore().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ begin()

template<typename T , size_t siz>
iterator begin ( )
inline

iterate over all the currently active Extents

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

References ExtentFamily< T, siz >::start_.

Referenced by BlockFlow< CONF >::allEpochs(), BlockFlow< CONF >::firstEpoch(), and BlockFlow< CONF >::until().

+ Here is the caller graph for this function:

◆ end()

template<typename T , size_t siz>
iterator end ( )
inline

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

References ExtentFamily< T, siz >::after_.

Referenced by BlockFlow< CONF >::until().

+ Here is the caller graph for this function:

◆ empty()

template<typename T , size_t siz>
bool empty ( ) const
inline

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

References ExtentFamily< T, siz >::after_, and ExtentFamily< T, siz >::start_.

Referenced by ExtentFamily< T, siz >::last().

+ Here is the caller graph for this function:

◆ last()

template<typename T , size_t siz>
iterator last ( )
inline

positioned to the last / latest storage extent opened

Warning
undefined behaviour when empty

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

References ExtentFamily< T, siz >::after_, ExtentFamily< T, siz >::empty(), ExtentFamily< T, siz >::incWrap(), and ExtentFamily< T, siz >::slotCnt().

Referenced by BlockFlow< CONF >::lastEpoch(), and ExtentFamily< T, siz >::openNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWrapped()

template<typename T , size_t siz>
bool isWrapped ( ) const
inlineprivate

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

References ExtentFamily< T, siz >::after_, and ExtentFamily< T, siz >::start_.

Referenced by ExtentFamily< T, siz >::activeSlotCnt(), ExtentFamily< T, siz >::isValidPos(), and ExtentFamily< T, siz >::openNew().

+ Here is the caller graph for this function:

◆ slotCnt()

template<typename T , size_t siz>
size_t slotCnt ( ) const
inlineprivate

◆ activeSlotCnt()

template<typename T , size_t siz>
size_t activeSlotCnt ( ) const
inlineprivate
Returns
number of allocated slots actually used

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

References ExtentFamily< T, siz >::after_, ExtentFamily< T, siz >::isWrapped(), ExtentFamily< T, siz >::slotCnt(), and ExtentFamily< T, siz >::start_.

Referenced by ExtentFamily< T, siz >::dropOld(), ExtentFamily< T, siz >::freeSlotCnt(), and ExtentFamily< T, siz >::isValidPos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ freeSlotCnt()

template<typename T , size_t siz>
size_t freeSlotCnt ( ) const
inlineprivate

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

References ExtentFamily< T, siz >::activeSlotCnt(), and ExtentFamily< T, siz >::slotCnt().

Referenced by ExtentFamily< T, siz >::canAccomodate(), and ExtentFamily< T, siz >::openNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canAccomodate()

template<typename T , size_t siz>
bool canAccomodate ( size_t  addCnt) const
inlineprivate

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

References ExtentFamily< T, siz >::freeSlotCnt().

Referenced by ExtentFamily< T, siz >::openNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ incWrap()

template<typename T , size_t siz>
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 328 of file extent-family.hpp.

References ExtentFamily< T, siz >::slotCnt().

Referenced by ExtentFamily< T, siz >::dropOld(), ExtentFamily< T, siz >::IdxLink::iterNext(), ExtentFamily< T, siz >::last(), and ExtentFamily< T, siz >::openNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidPos()

template<typename T , size_t siz>
bool isValidPos ( size_t  idx) const
inlineprivate

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

References ExtentFamily< T, siz >::activeSlotCnt(), ExtentFamily< T, siz >::after_, ExtentFamily< T, siz >::isWrapped(), ExtentFamily< T, siz >::slotCnt(), and ExtentFamily< T, siz >::start_.

Referenced by ExtentFamily< T, siz >::access(), and ExtentFamily< T, siz >::IdxLink::expandAlloc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matchPos()

template<typename T , size_t siz>
bool matchPos ( size_t  idx,
void *  address 
)
inlineprivate

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

References ExtentFamily< T, siz >::extents_, and ExtentFamily< T, siz >::slotCnt().

Referenced by ExtentFamily< T, siz >::IdxLink::validatePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ access()

template<typename T , size_t siz>
Extent & access ( size_t  idx) const
inlineprivate

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

References ExtentFamily< T, siz >::isValidPos().

Referenced by ExtentFamily< T, siz >::IdxLink::yield().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ___sanityCheckAllocSize()

template<typename T , size_t siz>
void ___sanityCheckAllocSize ( size_t  addCnt)
inlineprivate

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

References util::showSize(), and ExtentFamily< T, siz >::slotCnt().

Referenced by ExtentFamily< T, siz >::openNew().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ EXCESS_ALLOC

template<typename T , size_t siz>
const size_t EXCESS_ALLOC {5}
staticprivate

number of excess new extents to add whenever new storage is required

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

Referenced by ExtentFamily< T, siz >::openNew().

◆ extents_

template<typename T , size_t siz>
Extents extents_
private

◆ start_

◆ after_

Friends And Related Symbol Documentation

◆ ExtentDiagnostic< T, siz >

template<typename T , size_t siz>
friend class ExtentDiagnostic< T, siz >
friend

„backdoor“ to watch internals from tests

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

◆ begin

template<typename T , size_t siz>
iterator begin ( ExtentFamily< T, siz > &  exFam)
friend

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

◆ end

template<typename T , size_t siz>
iterator end ( ExtentFamily< T, siz > &  exFam)
friend

Definition at line 267 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: