tatami_chunked
Helpers to create custom chunked tatami matrices
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
tatami_chunked::DenseSlabFactory< Value_ > Struct Template Reference

Factory for dense slabs. More...

#include <DenseSlabFactory.hpp>

Classes

struct  Slab
 Dense slab. More...
 

Public Member Functions

 DenseSlabFactory (size_t slab_size, size_t max_slabs)
 
 DenseSlabFactory (const SlabCacheStats &stats)
 
Slab create ()
 

Detailed Description

template<typename Value_>
struct tatami_chunked::DenseSlabFactory< Value_ >

Factory for dense slabs.

An instance of this class allocates a single memory pool during its construction. Each slab is simply a pointer into this pool at regular offsets. The idea is to allocate one large block for caching in, e.g., LruSlabCache, improving performance by avoiding repeated requests to the allocator. This also reduces fragmentation that could increase memory usage beyond the expected cache size.

Template Parameters
Value_Type of the data in each slab.

Constructor & Destructor Documentation

◆ DenseSlabFactory() [1/2]

template<typename Value_ >
tatami_chunked::DenseSlabFactory< Value_ >::DenseSlabFactory ( size_t  slab_size,
size_t  max_slabs 
)
inline
Parameters
slab_sizeSize of the slab, in terms of data elements.
max_slabsMaximum number of slabs.

◆ DenseSlabFactory() [2/2]

template<typename Value_ >
tatami_chunked::DenseSlabFactory< Value_ >::DenseSlabFactory ( const SlabCacheStats stats)
inline
Parameters
statsSlab cache statistics.

Member Function Documentation

◆ create()

template<typename Value_ >
Slab tatami_chunked::DenseSlabFactory< Value_ >::create ( )
inline

Create a new slab, i.e., designate a portion of the memory pool for use through the returned pointer. This should not be called more than max_slabs times.

Returns
Slab containing a pointer to the memory pool.

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