// This class provides a facility similar to the CRT atexit(), except that
// we control when the callbacks are executed. Under Windows for a DLL they
// happen at a really bad time and under the loader lock. This facility is
// mostly used by base::Singleton.
//
// The usage is simple. Early in the main() or WinMain() scope create an
// AtExitManager object on the stack:
// int main(...) {
// base::AtExitManager exit_manager;
//
// }
// When the exit_manager object goes out of scope, all the registered
// callbacks and singleton destructors will be called.

exit_manager离开作用域,所有的回调函数,单例的析构函数将会被调用。


再看看头文件

class AtExitManager {
protected:
// This constructor will allow this instance of AtExitManager to be created
// even if one already exists. This should only be used for testing!
// AtExitManagers are kept on a global stack, and it will be removed during
// destruction. This allows you to shadow another AtExitManager.
AtExitManager(bool shadow); public:
typedef void (*AtExitCallbackType)(void*); AtExitManager(); // The dtor calls all the registered callbacks. Do not try to register more
// callbacks after this point.
~AtExitManager(); // Registers the specified function to be called at exit. The prototype of
// the callback function is void func().
static void RegisterCallback(AtExitCallbackType func, void* param); // Calls the functions registered with RegisterCallback in LIFO order. It
// is possible to register new callbacks after calling this function.
static void ProcessCallbacksNow();

使用方法很简单,只要在main函数最开始的地方,定义一个即可

int main(...)
{
base::AtExitManager exit_manager; ....
}

chromium之at_exit的更多相关文章

  1. chromium之lazy_instance

    先看看介绍 // The LazyInstance<Type, Traits> class manages a single instance of Type, // which will ...

  2. QT5利用chromium内核与HTML页面交互

    在QT5.4之前,做QT开发浏览器只能选择QWebkit,但是有过使用的都会发现,这个webkit不是出奇的慢,简直是慢的令人发指,Release模式下还行,debug下你就无语了,但是webkit毕 ...

  3. Google之Chromium浏览器源码学习——base公共通用库(一)

    Google的优秀C++开源项目繁多,其中的Chromium浏览器项目可以说是很具有代表性的,此外还包括其第三开发开源库或是自己的优秀开源库,可以根据需要抽取自己感兴趣的部分.在研究.学习该项目前的时 ...

  4. 如何在windows上编译Chromium (CEF3) 并加入MP3支持(二)

    时隔一年,再次编译cef3,独一无二的目的仍为加入mp3支持.新版本的编译环境和注意事项都已经发生了变化,于是再记录一下. 一.编译版本 cef版本号格式为X.YYYY.A.gHHHHHHH X为主版 ...

  5. 如何在Windows上从源码编译Chromium (CEF3) 加入mp3支持

    一.什么是CEF CEF即Chromium Embeded Framework,由谷歌的开源浏览器项目Chromium扩展而来,可方便地嵌入其它程序中以得到浏览器功能. CEF包括CEF1和CEF3两 ...

  6. 构建基于Chromium的应用程序

    chromium是google chrome浏览器所采用的内核,最开始由苹果的webkit发展而出,由于webkit在发展上存在分歧,而google希望在开发上有更大的自由度,2013年google决 ...

  7. ubuntu中chromium无法播放flash,安装flash

    ubuntu14.0.4中系统自带的chromium无法播放flash,后来查了下,得知chromium已经不支持adobe flash了,用户可使用pepper flash替代.安装pepper f ...

  8. windows下编译chromium浏览器的15个流程整理

    编译chromium 系统为windows, 国内在windows上编译chromium的资料比较少, 我这篇文章只能作为参考, 记录我遇到的一些问题,因为chromium团队也会修改了代码,或者编译 ...

  9. Google之Chromium浏览器源码学习——base公共通用库(二)

    上次提到Chromium浏览器中base公共通用库中的内存分配器allocator,其中用到了三方库tcmalloc.jemalloc:对于这两个内存分配器,个人建议,对于内存,最好是自己维护内存池: ...

随机推荐

  1. PHP and laravel知识点小小积累

    function () use ($x, &$y){} 自从PHP5.3开始有了closure/匿名函数的概念,在这里的use关键词的作用是允许匿名函数capture到父函数scope 内存在 ...

  2. pt-mysql-summary

    pt-mysql-summary主要用来输出MySQL的基本信息,可以作为数据库巡检以及刚开始熟悉数据库环境时候进行使用: [root@mxqmongodb2 bin]# ./pt-mysql-sum ...

  3. .Net中初探Redis

    一.简介 Redis是著名的NOSQL数据库,本质就是存储键值对结构的数据,为存储键值对数据做了优化,在大型网站中应用很多.Redis提供了数据的自动过期处理,因此适合存储临时数据. 和Redis类似 ...

  4. M-PalindromeP-DP

    Palindrome Partitioning 动态规划+深度优先搜索 https://leetcode.com/discuss/23480/c-solution-with-dp-and-dfs-12 ...

  5. ppt中调整图片位置

    按方向键时,如果调整的位置过大,可以使用 Ctrl + 方向键.

  6. unity3d中设计模式的学习<一>:泛型单例

    单例是游戏开发中比较常见的设计模式,虽然针对的功能不同,但是有一些功能还是共有的,代码也不少,如果能放在一个基类里面是最好不过了,但是单例里需要有个instance功能来返回当前对象,所以这个功能必须 ...

  7. ZT 设计模式六大原则(5):迪米特法则

    转贴: 设计模式六大原则(5):迪米特法则   原帖子的后续评论里面很多值得仔细去看 切记!像21楼 21楼 chenshufei2 2012-09-23 12:47发表 [回复] 上个例子,就是方法 ...

  8. HashMap 和 ConcurrentHashMap,Java1.8版本

    1. HashMap Entry,一对kv就是一个Entry,还包括一些next指针,用来解决散列冲突. table,内部用来存储Entry的数组,resize时候table会成倍扩容. 容量,tab ...

  9. mongodb分片集群(无副本集)搭建

    数据分片节点#192.168.114.26#mongo.cnfport=2001dbpath=/data/mongodb/datalogpath=/data/mongodb/log/mongodb.l ...

  10. 针对ie的css hack

    /* IE9 , IE10 ,IE11 */ @media screen and (min-width:0\0) {   /* IE9 , IE10 ,IE11 rule sets go here * ...