46template <
typename Type,
typename Factory,
typename LockStrategy>
88 ut_ad(elem->m_pool ==
this);
122 return (elem !=
nullptr ? &elem->
m_type :
nullptr);
129 byte *
p =
reinterpret_cast<byte *
>(ptr + 1);
131 elem =
reinterpret_cast<Element *
>(
p -
sizeof(*elem));
143 typedef std::priority_queue<
Element *,
144 std::vector<Element *, ut::allocator<Element *>>,
145 std::greater<Element *>>
167 for (
size_t i = 0; i < n_elems; ++i, ++
m_last) {
196template <
typename Pool,
typename LockStrategy>
221 size_t n_pools =
m_pools.size();
229 if (ptr ==
nullptr && (index / n_pools) > 2) {
250 }
while (ptr ==
nullptr);
267 if (n_pools <
m_pools.size()) {
277 if (pool !=
nullptr) {
303 typename Pools::iterator it;
322 typedef std::vector<PoolType *, ut::allocator<PoolType *>>
Pools;
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
int destroy(azio_stream *s)
Definition: azio.cc:371
The class error is used to emit error messages.
Definition: ut0log.h:231
const char * p
Definition: ctype-mb.cc:1225
size_t size(const char *const c)
Definition: base64.h:46
Type
Definition: resource_group_basic_types.h:33
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:634
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:811
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:719
Definition: ut0pool.h:197
size_t m_size
Size of each block.
Definition: ut0pool.h:325
bool add_pool(size_t n_pools)
Add a new pool.
Definition: ut0pool.h:262
value_type * get()
Get an element from one of the pools.
Definition: ut0pool.h:211
LockStrategy m_lock_strategy
Lock strategy to use.
Definition: ut0pool.h:331
void create()
Create the pool manager.
Definition: ut0pool.h:294
PoolManager(const PoolManager &)
PoolManager(size_t size)
Definition: ut0pool.h:201
PoolManager & operator=(const PoolManager &)
Pools m_pools
Pools managed this manager.
Definition: ut0pool.h:328
~PoolManager()
Definition: ut0pool.h:203
PoolType::value_type value_type
Definition: ut0pool.h:199
std::vector< PoolType *, ut::allocator< PoolType * > > Pools
Definition: ut0pool.h:322
Pool PoolType
Definition: ut0pool.h:198
static void mem_free(value_type *ptr)
Definition: ut0pool.h:255
void destroy()
Release the resources.
Definition: ut0pool.h:302
Pool * m_pool
Definition: ut0pool.h:53
value_type m_type
Definition: ut0pool.h:54
Allocate the memory for the object in blocks.
Definition: ut0pool.h:47
LockStrategy m_lock_strategy
Lock strategy to use.
Definition: ut0pool.h:193
~Pool()
Destructor.
Definition: ut0pool.h:84
std::priority_queue< Element *, std::vector< Element *, ut::allocator< Element * > >, std::greater< Element * > > pqueue_t
Definition: ut0pool.h:146
Pool(size_t size)
Constructor.
Definition: ut0pool.h:59
void init(size_t n_elems)
Initialise the elements.
Definition: ut0pool.h:164
pqueue_t m_pqueue
Priority queue ordered on the pointer addresses.
Definition: ut0pool.h:190
Type value_type
Definition: ut0pool.h:48
Element * m_last
Upper limit of used space.
Definition: ut0pool.h:187
size_t m_size
Size of the block in bytes.
Definition: ut0pool.h:184
Element * m_end
Pointer to the last element.
Definition: ut0pool.h:178
static void mem_free(value_type *ptr)
Add the object to the pool.
Definition: ut0pool.h:127
Pool & operator=(const Pool &)
void put(Element *elem)
Release the object to the free pool.
Definition: ut0pool.h:150
Type * get()
Get an object from the pool.
Definition: ut0pool.h:99
Element * m_start
Pointer to the first element.
Definition: ut0pool.h:181
double seconds()
Definition: task.cc:310
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:566
static int added
Definition: xcom_statistics.cc:100