看看头文件怎么用

// Wrapper for thread local storage.  This class doesn't do much except provide
// an API for portability.
class ThreadLocalStorage {
public: // Prototype for the TLS destructor function, which can be optionally used to
// cleanup thread local storage on thread exit. 'value' is the data that is
// stored in thread local storage.
typedef void (*TLSDestructorFunc)(void* value); // A key representing one value stored in TLS.
class Slot {
public:
Slot(TLSDestructorFunc destructor = NULL); // This constructor should be used for statics.
// It returns an uninitialized Slot.
explicit Slot(base::LinkerInitialized x) {} // Set up the TLS slot. Called by the constructor.
// 'destructor' is a pointer to a function to perform per-thread cleanup of
// this object. If set to NULL, no cleanup is done for this TLS slot.
// Returns false on error.
bool Initialize(TLSDestructorFunc destructor); // Free a previously allocated TLS 'slot'.
// If a destructor was set for this slot, removes
// the destructor so that remaining threads exiting
// will not free data.
void Free(); // Get the thread-local value stored in slot 'slot'.
// Values are guaranteed to initially be zero.
void* Get() const; // Set the thread-local value stored in slot 'slot' to
// value 'value'.
void Set(void* value); bool initialized() const { return initialized_; } private:
// The internals of this struct should be considered private.
bool initialized_;
#if defined(OS_WIN)
int slot_;
#elif defined(OS_POSIX)
pthread_key_t key_;
#endif DISALLOW_COPY_AND_ASSIGN(Slot);
}; #if defined(OS_WIN)
// Function called when on thread exit to call TLS
// destructor functions. This function is used internally.
static void ThreadExit();
ThreadLocalStorage::Slot slot = new ThreadLocalStorage::Slot(..)
slot->Initialize
slot->Set

slot->Get

有个测试用例,蛮看一看
TEST(ThreadLocalStorageTest, Basics) {
ThreadLocalStorage::Slot slot;
slot.Set(reinterpret_cast<void*>());
int value = reinterpret_cast<intptr_t>(slot.Get());
EXPECT_EQ(value, );
}
 

chromium之ThreadLocalStorage的更多相关文章

  1. chromium之tracked_objects

    // For each thread, we have a ThreadData that stores all tracking info generated // on this thread. ...

  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. python中的字符串 列表 字典

    字符串     一个有序的字符集合  不可变 1,可以使用for in语句进行迭代循环,返回元素    2,in类是于str.find()方法但是是返回布尔结果        str.find()返回 ...

  2. Cocos2d-js 开发记录:声音播放

    声音播放可以使用cc.audioEngine,需要播放的文件在resource.js中进行添加如: button_press_mp3: "res/audio/press.mp3", ...

  3. Android 自定义圆形图表

    <com...SignChartView android:id="@+id/signChart" android:layout_width="265dp" ...

  4. ng-repeat和ng-options区别

    ng-repeat ="x in XXX" ng-options="x.*** for x in XXX“ ng-repeat 写法 <select> < ...

  5. check_mk通用应用检测插件

    客户端mk_tvmapp import json filename = '/tmp/tvmapp.json' print '<<<tvmapp>>>' for a ...

  6. js:JSON对象与JSON字符串转换

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式. 同时,JSON是 JavaScript 原生格式,这 ...

  7. Python——追加学习笔记(四)

    函数 1.python里的函数可以返回一个值或者对象,知识在返回一个容器对象的时候有点不同,看起来像是能返回多个对象. >>> def bar(): ... return 'abc' ...

  8. 7.Zabbix 3.0 web监控

    请查看我的有道云笔记: http://note.youdao.com/noteshare?id=5f6b67f98a802fb831a83d810969c583&sub=B8D5267BDD5 ...

  9. 函数名: lseek

    函数名: lseek 功 能: 移动文件读/写指针 头文件:#include <sys/types.h> #include <unistd.h> 用 法: off_t lsee ...

  10. OC @protocol(声明协议 )

    @protocol Study; int main(int argc, const char * argv[]) { @autoreleasepool { Student *stu = [[[Stud ...