MySQL 9.1.0
Source Code Documentation
ut::Object_cache< T > Class Template Reference

A class to manage objects of type T. More...

#include <ut0object_cache.h>

Public Member Functions

 ~Object_cache ()
 Destructor. More...
 
template<typename... Types>
dberr_t init (size_t size, size_t step, Types &&...args)
 Initialize the cache. More...
 
template<typename... Types>
T * allocate (Types &&...args)
 
template<typename... Types>
dberr_t extend (size_t size, Types &&...args)
 
void deallocate (T *obj)
 

Private Attributes

std::vector< T * > m_objects
 Cached objects. More...
 
size_t m_step {1}
 When the cache is extended, how many new objects needs to be created. More...
 
size_t m_index {0}
 Position of next object to be allocated. More...
 

Detailed Description

template<typename T>
class ut::Object_cache< T >

A class to manage objects of type T.

Constructor & Destructor Documentation

◆ ~Object_cache()

template<typename T >
ut::Object_cache< T >::~Object_cache ( )
inline

Destructor.

Frees the cached objects.

Member Function Documentation

◆ allocate()

template<typename T >
template<typename... Types>
T * ut::Object_cache< T >::allocate ( Types &&...  args)
inline

◆ deallocate()

template<typename T >
void ut::Object_cache< T >::deallocate ( T *  obj)
inline

◆ extend()

template<typename T >
template<typename... Types>
dberr_t ut::Object_cache< T >::extend ( size_t  size,
Types &&...  args 
)
inline

◆ init()

template<typename T >
template<typename... Types>
dberr_t ut::Object_cache< T >::init ( size_t  size,
size_t  step,
Types &&...  args 
)
inline

Initialize the cache.

Parameters
[in]sizeinitial number of objects to cache.
[in]stepwhen extending cache, number of objects to add.
[in]argsarguments to be passed to constructor of T

Member Data Documentation

◆ m_index

template<typename T >
size_t ut::Object_cache< T >::m_index {0}
private

Position of next object to be allocated.

◆ m_objects

template<typename T >
std::vector<T *> ut::Object_cache< T >::m_objects
private

Cached objects.

◆ m_step

template<typename T >
size_t ut::Object_cache< T >::m_step {1}
private

When the cache is extended, how many new objects needs to be created.


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