/******************************************************************//**
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. iOS上用FTGL显示定制Truetype字体碰到的问题

    没想到这个问题搞了快2个月时间:当然跟我只是断断续续地工作有关. FTGL是freetype的opengl实现.我接触FTGL最初只是为了练习OpenGL,写几个简单的游戏app.开始试了试FTGL觉 ...

  2. sql2008 计划自动创建数据库分区【转】

    本文转自:http://jingyan.baidu.com/article/6b97984d9a26ec1ca3b0bf77.html sql2008 计划自动创建数据库分区 固定增量的数据,自动创建 ...

  3. 无root权限安装python

    http://lujialong.com/?p=150 pipe 安装第三方包 http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip http://www.cn ...

  4. 如何使用Xcode6 调试UI,Reveal

    实际测试需要使用IOS8并且32-bit的设备:具体打开调试的方法有三种: 1.底部调试菜单中: 2,debug菜单中 3.debug navigator 中

  5. 剑指offer--面试题9

    题目一:求斐波那契数列第n项 自己所写代码如下: #include "stdafx.h" #include<iostream> long Fibonacci(unsig ...

  6. select模式

    在很多比较各种网络模型的文章中,但凡提到select模型时,都会说select受限于轮询的套接字数量,这个 数量也就是系统头文件中定义的FD_SETSIZE值(例如64).但事实上这个算不上真的限制. ...

  7. ssh-add 报错 Could not open a connection to your authentication agent

    ERROR: [root@testcentos01 ~]# ssh-add Could not open a connection to your authentication agent 在shel ...

  8. Eclipse和intellij idea 快捷键对比

    Eclipse和intellij idea 快捷键对比

  9. Android Service 的一些笔记

    绑定服务: 用于间接调用服务里面的方法.如果调用者Activity被销毁了,服务也跟着销毁了,服务也会跟着销毁. 开启服务: 不可以调用服务里面的方法.如果调用者的Activity退出了,服务还会长期 ...

  10. lintcode:Palindrome Partitioning 分割回文串

    题目: 分割回文串 给定一个字符串s,将s分割成一些子串,使每个子串都是回文串. 返回s所有可能的回文串分割方案. 样例 给出 s = "aab",返回 [ ["aa&q ...