/******************************************************************//**
Adds a block to the LRU list. Please make sure that the zip_size is
already set into the page zip when invoking the function, so that we
can get correct zip_size from the buffer page when adding a block
into LRU */
UNIV_INTERN
void
buf_LRU_add_block(
/*==============*/
    buf_page_t*    bpage,    /*!< in: control block */
    ibool        old)    /*!< in: TRUE if should be put to the old
                blocks in the LRU list, else put to the start;
                if the LRU list is very short, the block is
                added to the start, regardless of this
                parameter */
{
    buf_LRU_add_block_low(bpage, old);
}

/******************************************************************//**
Adds a block to the LRU list. Please make sure that the zip_size is
already set into the page zip when invoking the function, so that we
can get correct zip_size from the buffer page when adding a block
into LRU */
UNIV_INLINE
void
buf_LRU_add_block_low(
/*==================*/
    buf_page_t*    bpage,    /*!< in: control block */
    ibool        old)    /*!< in: TRUE if should be put to the old blocks
                in the LRU list, else put to the start; if the
                LRU list is very short, the block is added to
                the start, regardless of this parameter */
{
    buf_pool_t*    buf_pool = buf_pool_from_bpage(bpage);

    ut_ad(buf_pool);
    ut_ad(bpage);
    ut_ad(buf_pool_mutex_own(buf_pool));

    ut_a(buf_page_in_file(bpage));
    ut_ad(!bpage->in_LRU_list);

    if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) {

        UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, bpage);//插入到buff_pool头结点 详见

        bpage->freed_page_clock = buf_pool->freed_page_clock;
    } else {

        UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old,bpage);
        buf_pool->LRU_old_len++;
    }

    ut_d(bpage->in_LRU_list = TRUE);

    incr_LRU_size_in_bytes(bpage, buf_pool);

    

        ut_ad(buf_pool->LRU_old);

        /* Adjust the length of the old block list if necessary */

        buf_page_set_old(bpage, old);
        buf_LRU_old_adjust_len(buf_pool);//设置lru->old位置 详见

    } 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(buf_pool);
    } else {
        buf_page_set_old(bpage, buf_pool->LRU_old != NULL);
    }

    /* If this is a zipped block with decompressed frame as well
    then put it on the unzip_LRU list */
    if (buf_page_belongs_to_unzip_LRU(bpage)) {//如果是压缩的页,则放到uzip_lru中
        buf_unzip_LRU_add_block((buf_block_t*) bpage, old);
    }
}

函数buf_LRU_add_block的更多相关文章

  1. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  2. 探究javascript对象和数组的异同,及函数变量缓存技巧

    javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...

  3. JavaScript权威指南 - 函数

    函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...

  4. C++对C的函数拓展

    一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...

  5. 菜鸟Python学习笔记第一天:关于一些函数库的使用

    2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...

  6. javascript中的this与函数讲解

    前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...

  7. 复杂的 Hash 函数组合有意义吗?

    很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...

  8. JS核心系列:浅谈函数的作用域

    一.作用域(scope) 所谓作用域就是:变量在声明它们的函数体以及这个函数体嵌套的任意函数体内都是有定义的. function scope(){ var foo = "global&quo ...

  9. C++中的时间函数

    C++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...

随机推荐

  1. HDU 2121 Ice_cream’s world II 不定根最小树形图

    题目链接: 题目 Ice_cream's world II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  2. NYOJ-36 最长公共子序列 AC 分类: NYOJ 2014-01-03 20:54 155人阅读 评论(0) 收藏

    #include<stdio.h> #include<string.h> #define N 1010 #define max(x,y) x>y?x:y int dp() ...

  3. [转载]淘宝API调用 申请 获取session key

    http://www.cnblogs.com/zknu/archive/2013/06/14/3135527.html 在调用淘宝的API时,我们都会用到appkey,appsecret,appses ...

  4. Directx3D SimpleSample Sample

    在d3d 2010 june这个版本里的samples 不知道为什么SimpleSample Sample 这个 它的documents基本等于没有 Starting point for new Di ...

  5. Ubuntu的LTS版本

    Ubuntu的LTS版本什么意思 LTS是长期支持(Long Term Support)的缩写. 我们每六个月制作一个新的Ubuntu桌面和服务器的版本,这意味着你总能拥有开源世界提供的最新最好的应用 ...

  6. PV操作,

    P操作是先做减一操作,然后判读是否大于等于0. V操作是先做加一操作,然后判断是否大于0

  7. SQL语句备忘

    SELECT beatid,COUNT(d.id) dongnicount FROM `bed_beat_dongni` d INNER JOIN bed_beat b on b.id = d.bea ...

  8. java 页面换行处理

    在taxtarea中输入的文本.如果含有回车或空格.在界面上显示的时候则不哪么正常.回车消失了,空格变短了. 如何解决这个问题呢.有2种方法. 1.使用<pre>标签 w3c对pre元素是 ...

  9. WAF安恒

    http://wenku.baidu.com/view/c242927f581b6bd97e19ea1a.html?from=search

  10. MySQL 语句级避免重复插入—— Insert Select Not Exist

    想要插入一条数据,要避免重复插入,又不想折腾两回数据库连接操作,可以参考如下办法. INSERT INTO table(column1,column2,column3 ...columnN) SELE ...