MySQL 9.1.0
Source Code Documentation
Pool< Type, Factory, LockStrategy > Struct Template Reference

Allocate the memory for the object in blocks. More...

#include <ut0pool.h>

Classes

struct  Element
 

Public Types

typedef Type value_type
 

Public Member Functions

 Pool (size_t size)
 Constructor. More...
 
 ~Pool ()
 Destructor. More...
 
Type * get ()
 Get an object from the pool. More...
 

Static Public Member Functions

static void mem_free (value_type *ptr)
 Add the object to the pool. More...
 

Protected Member Functions

 Pool (const Pool &)
 
Pooloperator= (const Pool &)
 

Private Types

typedef std::priority_queue< Element *, std::vector< Element *, ut::allocator< Element * > >, std::greater< Element * > > pqueue_t
 

Private Member Functions

void put (Element *elem)
 Release the object to the free pool. More...
 
void init (size_t n_elems)
 Initialise the elements. More...
 

Private Attributes

Elementm_end
 Pointer to the last element. More...
 
Elementm_start
 Pointer to the first element. More...
 
size_t m_size
 Size of the block in bytes. More...
 
Elementm_last
 Upper limit of used space. More...
 
pqueue_t m_pqueue
 Priority queue ordered on the pointer addresses. More...
 
LockStrategy m_lock_strategy
 Lock strategy to use. More...
 

Detailed Description

template<typename Type, typename Factory, typename LockStrategy>
struct Pool< Type, Factory, LockStrategy >

Allocate the memory for the object in blocks.

We keep the objects sorted on pointer so that they are closer together in case they have to be iterated over in a list.

Member Typedef Documentation

◆ pqueue_t

template<typename Type , typename Factory , typename LockStrategy >
typedef std::priority_queue<Element *, std::vector<Element *, ut::allocator<Element *> >, std::greater<Element *> > Pool< Type, Factory, LockStrategy >::pqueue_t
private

◆ value_type

template<typename Type , typename Factory , typename LockStrategy >
typedef Type Pool< Type, Factory, LockStrategy >::value_type

Constructor & Destructor Documentation

◆ Pool() [1/2]

template<typename Type , typename Factory , typename LockStrategy >
Pool< Type, Factory, LockStrategy >::Pool ( size_t  size)
inline

Constructor.

Parameters
sizesize of the memory block

◆ ~Pool()

template<typename Type , typename Factory , typename LockStrategy >
Pool< Type, Factory, LockStrategy >::~Pool ( )
inline

Destructor.

◆ Pool() [2/2]

template<typename Type , typename Factory , typename LockStrategy >
Pool< Type, Factory, LockStrategy >::Pool ( const Pool< Type, Factory, LockStrategy > &  )
protected

Member Function Documentation

◆ get()

template<typename Type , typename Factory , typename LockStrategy >
Type * Pool< Type, Factory, LockStrategy >::get ( )
inline

Get an object from the pool.

Returns
a free instance or NULL if exhausted.

◆ init()

template<typename Type , typename Factory , typename LockStrategy >
void Pool< Type, Factory, LockStrategy >::init ( size_t  n_elems)
inlineprivate

Initialise the elements.

Parameters
n_elemsNumber of elements to initialise

◆ mem_free()

template<typename Type , typename Factory , typename LockStrategy >
static void Pool< Type, Factory, LockStrategy >::mem_free ( value_type ptr)
inlinestatic

Add the object to the pool.

Parameters
ptrobject to free

◆ operator=()

template<typename Type , typename Factory , typename LockStrategy >
Pool & Pool< Type, Factory, LockStrategy >::operator= ( const Pool< Type, Factory, LockStrategy > &  )
protected

◆ put()

template<typename Type , typename Factory , typename LockStrategy >
void Pool< Type, Factory, LockStrategy >::put ( Element elem)
inlineprivate

Release the object to the free pool.

Parameters
elemelement to free

Member Data Documentation

◆ m_end

template<typename Type , typename Factory , typename LockStrategy >
Element* Pool< Type, Factory, LockStrategy >::m_end
private

Pointer to the last element.

◆ m_last

template<typename Type , typename Factory , typename LockStrategy >
Element* Pool< Type, Factory, LockStrategy >::m_last
private

Upper limit of used space.

◆ m_lock_strategy

template<typename Type , typename Factory , typename LockStrategy >
LockStrategy Pool< Type, Factory, LockStrategy >::m_lock_strategy
private

Lock strategy to use.

◆ m_pqueue

template<typename Type , typename Factory , typename LockStrategy >
pqueue_t Pool< Type, Factory, LockStrategy >::m_pqueue
private

Priority queue ordered on the pointer addresses.

◆ m_size

template<typename Type , typename Factory , typename LockStrategy >
size_t Pool< Type, Factory, LockStrategy >::m_size
private

Size of the block in bytes.

◆ m_start

template<typename Type , typename Factory , typename LockStrategy >
Element* Pool< Type, Factory, LockStrategy >::m_start
private

Pointer to the first element.


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