/******************************************************************//**
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. c#之反射总结

     1.了解什么事程序集 2.加载程序集 首先要加载需要加载的程序集,然后找到指定的类型,进而往下进行动态加载. 要加载的程序集中的内容: public class Class1:Person { pr ...

  2. LintCode-Majority Number

    Given an array of integers, the majority number is the number that occurs more than half of the size ...

  3. IIS 分析器错误消息: 未能加载类型“_Default”

    还会出现不能加载程序集,如: using Model;using BLL;  均报错 但是在vs2012  iis express中调试正常, 按照网上方法: 我将vs  web项目下的目录全部cop ...

  4. Sublime key bindings使用

    开启vi mode后,可以使用很多的VI快捷方式,所以我的sublime已经不是单纯的st了,st的VI模式不完全支持所有的快捷键.我们来看一段官网的key bindings示例: { "k ...

  5. mysql memory

    mysql memory engine 创建: mysql> create table mt engine = memory select * from information_schema.t ...

  6. ffmpeg mp3转ogg的命令

    ffmpeg.exe -y -i bb.mp3 -acodec libvorbis -ab 128k bb.ogg

  7. memcached+memadmin

    一.安装apache yum install httpd 二.安装php yum install php* 三.apache配置 vi /etc/httpd/conf/httpd.conf 添加Add ...

  8. Codeforces400D Dima and Bacteria

    题意:给你一个无向有权的图,图上的点被分成了几类,对于同类的点你需要判断它们之间相互的最短距离是不是0.满足这个条件之后要输出的是类与类之间的最短距离的矩阵.点给到10^5这么多,判断同类的点显然不能 ...

  9. hdu 1269 迷宫城堡(强联通分量,基础)

    这是一道模版题 题目 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include ...

  10. 02 - Tomcat配置

    Tomcat配置 本文内容 介绍 Windows UNIX daemon 1.介绍 首选看Tomcat目录下的RUNNING.TXT 2.Windows平台下 可以选择下载windows instal ...