码迷,mamicode.com
首页 > 其他好文 > 详细

函数buf_LRU_get_free_only

时间:2015-11-24 00:59:29      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:

 

/******************************************************************//**
Returns a free block from the buf_pool.  The block is taken off the
free list.  If it is empty, returns NULL.
@return    a free control block, or NULL if the buf_block->free list is empty */
UNIV_INTERN
buf_block_t*
buf_LRU_get_free_only(
/*==================*/
    buf_pool_t*    buf_pool)
{
    buf_block_t*    block;

    ut_ad(buf_pool_mutex_own(buf_pool));

    block = (buf_block_t*) UT_LIST_GET_FIRST(buf_pool->free);

    if (block) {

        ut_ad(block->page.in_free_list);
        ut_d(block->page.in_free_list = FALSE);
        ut_ad(!block->page.in_flush_list);
        ut_ad(!block->page.in_LRU_list);
        ut_a(!buf_page_in_file(&block->page));
        UT_LIST_REMOVE(list, buf_pool->free, (&block->page));

        mutex_enter(&block->mutex);

        buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
        UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE);

        ut_ad(buf_pool_from_block(block) == buf_pool);

        mutex_exit(&block->mutex);
    }

    return(block);
}

 

函数buf_LRU_get_free_only

标签:

原文地址:http://www.cnblogs.com/taek/p/4990081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!