45template <
typename Type,
typename Factory,
typename LockStrategy>
87 ut_ad(elem->m_pool ==
this);
121 return (elem !=
nullptr ? &elem->
m_type :
nullptr);
128 byte *
p =
reinterpret_cast<byte *
>(ptr + 1);
130 elem =
reinterpret_cast<Element *
>(
p -
sizeof(*elem));
142 typedef std::priority_queue<
Element *,
143 std::vector<Element *, ut::allocator<Element *>>,
144 std::greater<Element *>>
166 for (
size_t i = 0; i < n_elems; ++i, ++
m_last) {
195template <
typename Pool,
typename LockStrategy>
220 size_t n_pools =
m_pools.size();
228 if (ptr ==
nullptr && (index / n_pools) > 2) {
249 }
while (ptr ==
nullptr);
266 if (n_pools <
m_pools.size()) {
276 if (pool !=
nullptr) {
302 typename Pools::iterator it;
321 typedef std::vector<PoolType *, ut::allocator<PoolType *>>
Pools;
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:570
int destroy(azio_stream *s)
Definition: azio.cc:371
The class error is used to emit error messages.
Definition: ut0log.h:230
const char * p
Definition: ctype-mb.cc:1234
Type
Definition: resource_group_basic_types.h:32
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:631
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:808
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:716
Definition: ut0pool.h:196
size_t m_size
Size of each block.
Definition: ut0pool.h:324
bool add_pool(size_t n_pools)
Add a new pool.
Definition: ut0pool.h:261
value_type * get()
Get an element from one of the pools.
Definition: ut0pool.h:210
LockStrategy m_lock_strategy
Lock strategy to use.
Definition: ut0pool.h:330
void create()
Create the pool manager.
Definition: ut0pool.h:293
PoolManager(const PoolManager &)
PoolManager(size_t size)
Definition: ut0pool.h:200
PoolManager & operator=(const PoolManager &)
Pools m_pools
Pools managed this manager.
Definition: ut0pool.h:327
~PoolManager()
Definition: ut0pool.h:202
PoolType::value_type value_type
Definition: ut0pool.h:198
std::vector< PoolType *, ut::allocator< PoolType * > > Pools
Definition: ut0pool.h:321
Pool PoolType
Definition: ut0pool.h:197
static void mem_free(value_type *ptr)
Definition: ut0pool.h:254
void destroy()
Release the resources.
Definition: ut0pool.h:301
Pool * m_pool
Definition: ut0pool.h:52
value_type m_type
Definition: ut0pool.h:53
Allocate the memory for the object in blocks.
Definition: ut0pool.h:46
LockStrategy m_lock_strategy
Lock strategy to use.
Definition: ut0pool.h:192
~Pool()
Destructor.
Definition: ut0pool.h:83
std::priority_queue< Element *, std::vector< Element *, ut::allocator< Element * > >, std::greater< Element * > > pqueue_t
Definition: ut0pool.h:145
Pool(size_t size)
Constructor.
Definition: ut0pool.h:58
void init(size_t n_elems)
Initialise the elements.
Definition: ut0pool.h:163
pqueue_t m_pqueue
Priority queue ordered on the pointer addresses.
Definition: ut0pool.h:189
Type value_type
Definition: ut0pool.h:47
Element * m_last
Upper limit of used space.
Definition: ut0pool.h:186
size_t m_size
Size of the block in bytes.
Definition: ut0pool.h:183
Element * m_end
Pointer to the last element.
Definition: ut0pool.h:177
static void mem_free(value_type *ptr)
Add the object to the pool.
Definition: ut0pool.h:126
Pool & operator=(const Pool &)
void put(Element *elem)
Release the object to the free pool.
Definition: ut0pool.h:149
Type * get()
Get an object from the pool.
Definition: ut0pool.h:98
Element * m_start
Pointer to the first element.
Definition: ut0pool.h:180
double seconds()
Definition: task.cc:309
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:104
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:92
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:563
static int added
Definition: xcom_statistics.cc:99