本文整理汇总了C++中UT_LIST_GET_LEN函数的典型用法代码示例。如果您正苦于以下问题:C++ UT_LIST_GET_LEN函数的具体用法?C++ UT_LIST_GET_LEN怎么用?C++ UT_LIST_GET_LEN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UT_LIST_GET_LEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mem_pool_print_info
/********************************************************************//**
Prints info of a memory pool. */
UNIV_INTERN
void
mem_pool_print_info(
/*================*/
FILE* outfile,/*!< in: output file to write to */
mem_pool_t* pool) /*!< in: memory pool */
{
ulint i;
mem_pool_validate(pool);
fprintf(outfile, "INFO OF A MEMORY POOL\n");
mutex_enter(&(pool->mutex));
for (i = 0; i < 64; i++) {
if (UT_LIST_GET_LEN(pool->free_list[i]) > 0) {
fprintf(outfile,
"Free list length %lu for"
" blocks of size %lu\n",
(ulong) UT_LIST_GET_LEN(pool->free_list[i]),
(ulong) ut_2_exp(i));
}
}
fprintf(outfile, "Pool size %lu, reserved %lu.\n", (ulong) pool->size,
(ulong) pool->reserved);
mutex_exit(&(pool->mutex));
}
示例2: buf_LRU_old_init
/***********************************************************************
Initializes the old blocks pointer in the LRU list. This function should be
called when the LRU list grows to BUF_LRU_OLD_MIN_LEN length. */
static
void
buf_LRU_old_init(void)
/*==================*/
{
buf_block_t* block;
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN);
/* We first initialize all blocks in the LRU list as old and then use
the adjust function to move the LRU_old pointer to the right
position */
block = UT_LIST_GET_FIRST(buf_pool->LRU);
while (block != NULL) {
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(block->in_LRU_list);
block->old = TRUE;
block = UT_LIST_GET_NEXT(LRU, block);
}
buf_pool->LRU_old = UT_LIST_GET_FIRST(buf_pool->LRU);
buf_pool->LRU_old_len = UT_LIST_GET_LEN(buf_pool->LRU);
buf_LRU_old_adjust_len();
}
示例3: buf_LRU_add_block_to_end_low
/**********************************************************************
Adds a block to the LRU list end. */
UNIV_INLINE
void
buf_LRU_add_block_to_end_low(
/*=========================*/
buf_block_t* block) /* in: control block */
{
buf_block_t* last_block;
ut_ad(buf_pool);
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
block->old = TRUE;
last_block = UT_LIST_GET_LAST(buf_pool->LRU);
if (last_block) {
block->LRU_position = last_block->LRU_position;
} else {
block->LRU_position = buf_pool_clock_tic();
}
ut_a(!block->in_LRU_list);
UT_LIST_ADD_LAST(LRU, buf_pool->LRU, block);
block->in_LRU_list = TRUE;
if (srv_use_awe && block->frame) {
/* Add to the list of mapped pages */
UT_LIST_ADD_LAST(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block);
}
if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
buf_pool->LRU_old_len++;
}
if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
ut_ad(buf_pool->LRU_old);
/* Adjust the length of the old block list if necessary */
buf_LRU_old_adjust_len();
} else if (UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN) {
/* The LRU list is now long enough for LRU_old to become
defined: init it */
buf_LRU_old_init();
}
}
示例4: trx_weight_cmp
int
trx_weight_cmp(
/*===========*/
/* out: <0, 0 or >0; similar to strcmp(3) */
trx_t* a, /* in: the first transaction to be compared */
trx_t* b) /* in: the second transaction to be compared */
{
ibool a_notrans_edit;
ibool b_notrans_edit;
/* If mysql_thd is NULL for a transaction we assume that it has
not edited non-transactional tables. */
a_notrans_edit = a->mysql_thd != NULL
&& thd_has_edited_nontrans_tables(a->mysql_thd);
b_notrans_edit = b->mysql_thd != NULL
&& thd_has_edited_nontrans_tables(b->mysql_thd);
if (a_notrans_edit && !b_notrans_edit) {
return(1);
}
if (!a_notrans_edit && b_notrans_edit) {
return(-1);
}
/* Either both had edited non-transactional tables or both had
not, we fall back to comparing the number of altered/locked
rows. */
#if 0
fprintf(stderr,
"%s TRX_WEIGHT(a): %lld+%lu, TRX_WEIGHT(b): %lld+%lu\n",
__func__,
ut_conv_dulint_to_longlong(a->undo_no),
UT_LIST_GET_LEN(a->trx_locks),
ut_conv_dulint_to_longlong(b->undo_no),
UT_LIST_GET_LEN(b->trx_locks));
#endif
#define TRX_WEIGHT(t) \
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b)));
}
示例5: buf_LRU_get_recent_limit
ulint
buf_LRU_get_recent_limit(void)
/*==========================*/
/* out: the limit; zero if could not determine it */
{
buf_block_t* block;
ulint len;
ulint limit;
mutex_enter(&(buf_pool->mutex));
len = UT_LIST_GET_LEN(buf_pool->LRU);
if (len < BUF_LRU_OLD_MIN_LEN) {
/* The LRU list is too short to do read-ahead */
mutex_exit(&(buf_pool->mutex));
return(0);
}
block = UT_LIST_GET_FIRST(buf_pool->LRU);
limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
mutex_exit(&(buf_pool->mutex));
return(limit);
}
示例6: trx_assign_rseg
/******************************************************************//**
Assigns a rollback segment to a transaction in a round-robin fashion.
Skips the SYSTEM rollback segment if another is available.
@return assigned rollback segment id */
UNIV_INLINE
ulint
trx_assign_rseg(void)
/*=================*/
{
trx_rseg_t* rseg = trx_sys->latest_rseg;
ut_ad(mutex_own(&kernel_mutex));
loop:
/* Get next rseg in a round-robin fashion */
rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
if (rseg == NULL) {
rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
}
/* If it is the SYSTEM rollback segment, and there exist others, skip
it */
if ((rseg->id == TRX_SYS_SYSTEM_RSEG_ID)
&& (UT_LIST_GET_LEN(trx_sys->rseg_list) > 1)) {
goto loop;
}
trx_sys->latest_rseg = rseg;
return(rseg->id);
}
示例7: buf_LRU_remove_block
/**********************************************************************
Removes a block from the LRU list. */
UNIV_INLINE
void
buf_LRU_remove_block(
/*=================*/
buf_block_t* block) /* in: control block */
{
ut_ad(buf_pool);
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(block->in_LRU_list);
/* If the LRU_old pointer is defined and points to just this block,
move it backward one step */
if (block == buf_pool->LRU_old) {
/* Below: the previous block is guaranteed to exist, because
the LRU_old pointer is only allowed to differ by the
tolerance value from strict 3/8 of the LRU list length. */
buf_pool->LRU_old = UT_LIST_GET_PREV(LRU, block);
(buf_pool->LRU_old)->old = TRUE;
buf_pool->LRU_old_len++;
ut_a(buf_pool->LRU_old);
}
/* Remove the block from the LRU list */
UT_LIST_REMOVE(LRU, buf_pool->LRU, block);
block->in_LRU_list = FALSE;
if (srv_use_awe && block->frame) {
/* Remove from the list of mapped pages */
UT_LIST_REMOVE(awe_LRU_free_mapped,
buf_pool->awe_LRU_free_mapped, block);
}
/* If the LRU list is so short that LRU_old not defined, return */
if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN) {
buf_pool->LRU_old = NULL;
return;
}
ut_ad(buf_pool->LRU_old);
/* Update the LRU_old_len field if necessary */
if (block->old) {
buf_pool->LRU_old_len--;
}
/* Adjust the length of the old block list if necessary */
buf_LRU_old_adjust_len();
}
示例8: ha_print_info
/*************************************************************//**
Prints info of a hash table. */
UNIV_INTERN
void
ha_print_info(
/*==========*/
FILE* file, /*!< in: file where to print */
hash_table_t* table) /*!< in: hash table */
{
#ifdef UNIV_DEBUG
/* Some of the code here is disabled for performance reasons in production
builds, see http://bugs.mysql.com/36941 */
#define PRINT_USED_CELLS
#endif /* UNIV_DEBUG */
#ifdef PRINT_USED_CELLS
hash_cell_t* cell;
ulint cells = 0;
ulint i;
#endif /* PRINT_USED_CELLS */
ulint n_bufs;
ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
#ifdef PRINT_USED_CELLS
for (i = 0; i < hash_get_n_cells(table); i++) {
cell = hash_get_nth_cell(table, i);
if (cell->node) {
cells++;
}
}
#endif /* PRINT_USED_CELLS */
fprintf(file, "Hash table size %lu",
(ulong) hash_get_n_cells(table));
#ifdef PRINT_USED_CELLS
fprintf(file, ", used cells %lu", (ulong) cells);
#endif /* PRINT_USED_CELLS */
if (table->heaps == NULL && table->heap != NULL) {
/* This calculation is intended for the adaptive hash
index: how many buffer frames we have reserved? */
n_bufs = UT_LIST_GET_LEN(table->heap->base) - 1;
if (table->heap->free_block) {
n_bufs++;
}
fprintf(file, ", node heap has %lu buffer(s)\n",
(ulong) n_bufs);
}
}
示例9: trx_rseg_mem_free
/***********************************************************************//**
Free's an instance of the rollback segment in memory. */
UNIV_INTERN
void
trx_rseg_mem_free(
/*==============*/
trx_rseg_t* rseg) /* in, own: instance to free */
{
trx_undo_t* undo;
mutex_free(&rseg->mutex);
if (!srv_apply_log_only) {
/* There can't be any active transactions. */
ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0);
ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0);
}
undo = UT_LIST_GET_FIRST(rseg->update_undo_cached);
while (undo != NULL) {
trx_undo_t* prev_undo = undo;
undo = UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_list, rseg->update_undo_cached, prev_undo);
trx_undo_mem_free(prev_undo);
}
undo = UT_LIST_GET_FIRST(rseg->insert_undo_cached);
while (undo != NULL) {
trx_undo_t* prev_undo = undo;
undo = UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_list, rseg->insert_undo_cached, prev_undo);
trx_undo_mem_free(prev_undo);
}
trx_sys_set_nth_rseg(trx_sys, rseg->id, NULL);
mem_free(rseg);
}
示例10: buf_LRU_buf_pool_running_out
ibool
buf_LRU_buf_pool_running_out(void)
/*==============================*/
/* out: TRUE if less than 25 % of buffer pool
left */
{
ibool ret = FALSE;
mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
ret = TRUE;
}
mutex_exit(&(buf_pool->mutex));
return(ret);
}
示例11: mutex_free
/******************************************************************//**
Calling this function is obligatory only if the memory buffer containing
the mutex is freed. Removes a mutex object from the mutex list. The mutex
is checked to be in the reset state. */
UNIV_INTERN
void
mutex_free(
/*=======*/
mutex_t* mutex) /*!< in: mutex */
{
ut_ad(mutex_validate(mutex));
ut_a(mutex_get_lock_word(mutex) == 0);
ut_a(mutex_get_waiters(mutex) == 0);
#ifdef UNIV_MEM_DEBUG
if (mutex == &mem_hash_mutex) {
ut_ad(UT_LIST_GET_LEN(mutex_list) == 1);
ut_ad(UT_LIST_GET_FIRST(mutex_list) == &mem_hash_mutex);
UT_LIST_REMOVE(list, mutex_list, mutex);
goto func_exit;
}
#endif /* UNIV_MEM_DEBUG */
if (mutex != &mutex_list_mutex
#ifdef UNIV_SYNC_DEBUG
&& mutex != &sync_thread_mutex
#endif /* UNIV_SYNC_DEBUG */
) {
mutex_enter(&mutex_list_mutex);
ut_ad(!UT_LIST_GET_PREV(list, mutex)
|| UT_LIST_GET_PREV(list, mutex)->magic_n
== MUTEX_MAGIC_N);
ut_ad(!UT_LIST_GET_NEXT(list, mutex)
|| UT_LIST_GET_NEXT(list, mutex)->magic_n
== MUTEX_MAGIC_N);
UT_LIST_REMOVE(list, mutex_list, mutex);
mutex_exit(&mutex_list_mutex);
}
os_event_free(mutex->event);
#ifdef UNIV_MEM_DEBUG
func_exit:
#endif /* UNIV_MEM_DEBUG */
#if !defined(HAVE_ATOMIC_BUILTINS)
os_fast_mutex_free(&(mutex->os_fast_mutex));
#endif
/* If we free the mutex protecting the mutex list (freeing is
not necessary), we have to reset the magic number AFTER removing
it from the list. */
#ifdef UNIV_DEBUG
mutex->magic_n = 0;
#endif /* UNIV_DEBUG */
}
示例12: trx_roll_savepoint_free
/*******************************************************************//**
Frees a single savepoint struct. */
UNIV_INTERN
void
trx_roll_savepoint_free(
/*=====================*/
trx_t* trx, /*!< in: transaction handle */
trx_named_savept_t* savep) /*!< in: savepoint to free */
{
ut_a(savep != NULL);
ut_a(UT_LIST_GET_LEN(trx->trx_savepoints) > 0);
UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
mem_free(savep->name);
mem_free(savep);
}
示例13: dict_build_index_def_step
/***************************************************************//**
Builds an index definition row to insert.
@return DB_SUCCESS or error code */
static
ulint
dict_build_index_def_step(
/*======================*/
que_thr_t* thr, /*!< in: query thread */
ind_node_t* node) /*!< in: index create node */
{
dict_table_t* table;
dict_index_t* index;
dtuple_t* row;
trx_t* trx;
ut_ad(mutex_own(&(dict_sys->mutex)));
trx = thr_get_trx(thr);
index = node->index;
table = dict_table_get_low(index->table_name);
if (table == NULL) {
return(DB_TABLE_NOT_FOUND);
}
trx->table_id = table->id;
node->table = table;
ut_ad((UT_LIST_GET_LEN(table->indexes) > 0)
|| dict_index_is_clust(index));
dict_hdr_get_new_id(NULL, &index->id, NULL);
/* Inherit the space id from the table; we store all indexes of a
table in the same tablespace */
index->space = table->space;
node->page_no = FIL_NULL;
row = dict_create_sys_indexes_tuple(index, node->heap);
node->ind_row = row;
ins_node_set_new_row(node->ind_def, row);
/* Note that the index was created by this transaction. */
index->trx_id = trx->id;
return(DB_SUCCESS);
}
示例14: sess_try_close
ibool
sess_try_close(
/*===========*/
/* out: TRUE if closed */
sess_t* sess) /* in, own: session object */
{
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
if (UT_LIST_GET_LEN(sess->graphs) == 0) {
sess_close(sess);
return(TRUE);
}
return(FALSE);
}
示例15: dict_build_index_def_step
/*******************************************************************
Builds an index definition row to insert. */
static
ulint
dict_build_index_def_step(
/*======================*/
/* out: DB_SUCCESS or error code */
que_thr_t* thr, /* in: query thread */
ind_node_t* node) /* in: index create node */
{
dict_table_t* table;
dict_index_t* index;
dtuple_t* row;
trx_t* trx;
ut_ad(mutex_own(&(dict_sys->mutex)));
trx = thr_get_trx(thr);
index = node->index;
table = dict_table_get_low(index->table_name);
if (table == NULL) {
return(DB_TABLE_NOT_FOUND);
}
trx->table_id = table->id;
node->table = table;
ut_ad((UT_LIST_GET_LEN(table->indexes) > 0)
|| (index->type & DICT_CLUSTERED));
index->id = dict_hdr_get_new_id(DICT_HDR_INDEX_ID);
/* Inherit the space id from the table; we store all indexes of a
table in the same tablespace */
index->space = table->space;
node->page_no = FIL_NULL;
row = dict_create_sys_indexes_tuple(index, node->heap);
node->ind_row = row;
ins_node_set_new_row(node->ind_def, row);
return(DB_SUCCESS);
}