chromium之ThreadLocalStorage
看看头文件怎么用
// 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的更多相关文章
- chromium之tracked_objects
// For each thread, we have a ThreadData that stores all tracking info generated // on this thread. ...
- QT5利用chromium内核与HTML页面交互
在QT5.4之前,做QT开发浏览器只能选择QWebkit,但是有过使用的都会发现,这个webkit不是出奇的慢,简直是慢的令人发指,Release模式下还行,debug下你就无语了,但是webkit毕 ...
- Google之Chromium浏览器源码学习——base公共通用库(一)
Google的优秀C++开源项目繁多,其中的Chromium浏览器项目可以说是很具有代表性的,此外还包括其第三开发开源库或是自己的优秀开源库,可以根据需要抽取自己感兴趣的部分.在研究.学习该项目前的时 ...
- 如何在windows上编译Chromium (CEF3) 并加入MP3支持(二)
时隔一年,再次编译cef3,独一无二的目的仍为加入mp3支持.新版本的编译环境和注意事项都已经发生了变化,于是再记录一下. 一.编译版本 cef版本号格式为X.YYYY.A.gHHHHHHH X为主版 ...
- 如何在Windows上从源码编译Chromium (CEF3) 加入mp3支持
一.什么是CEF CEF即Chromium Embeded Framework,由谷歌的开源浏览器项目Chromium扩展而来,可方便地嵌入其它程序中以得到浏览器功能. CEF包括CEF1和CEF3两 ...
- 构建基于Chromium的应用程序
chromium是google chrome浏览器所采用的内核,最开始由苹果的webkit发展而出,由于webkit在发展上存在分歧,而google希望在开发上有更大的自由度,2013年google决 ...
- ubuntu中chromium无法播放flash,安装flash
ubuntu14.0.4中系统自带的chromium无法播放flash,后来查了下,得知chromium已经不支持adobe flash了,用户可使用pepper flash替代.安装pepper f ...
- windows下编译chromium浏览器的15个流程整理
编译chromium 系统为windows, 国内在windows上编译chromium的资料比较少, 我这篇文章只能作为参考, 记录我遇到的一些问题,因为chromium团队也会修改了代码,或者编译 ...
- Google之Chromium浏览器源码学习——base公共通用库(二)
上次提到Chromium浏览器中base公共通用库中的内存分配器allocator,其中用到了三方库tcmalloc.jemalloc:对于这两个内存分配器,个人建议,对于内存,最好是自己维护内存池: ...
随机推荐
- Spring Data JPA简单使用
用Spring Data JPA操作数据库 这份教程教你用Spring Data JPA从关系数据库mysql中存储和提取数据.总结来自https://spring.io/guides/gs/acce ...
- python的返回值
1.返回值的作用 函数并非总是直接显示输出,相反,它可以处理一些数据,并返回一个或一组值.函数返回的值被称为返回值.在函数中,可使用return语句将值返回到调用函数的代码行.返回值让你能够将程序的大 ...
- Junit入门教程
做开发的时候,完成一个接口.方法.函数或者功能等,需要测试,是否有bug,有逻辑错误.这里有两种方案测试 1. 在main中写测试方法 2. 使用开源框架,这里使用的junit main写测试方法优点 ...
- 数据分析核心包——pandas
一.pandas简介 pandas是一个强大的Python数据分析的工具包,是基于NumPy构建的. 1.pandas的主要功能 (1)具备对其功能的数据结构DataFrame.Series (2)集 ...
- Django的模型层
一.ORM简介 MVC或者MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的减轻了开发人 ...
- CocoaPods管理的项目移植到别人电脑后找不到头文件
CocoaPods管理的项目移植到别人电脑后找不到头文件 在TARGETS -> Search Paths -> User Header Search Paths 中 写入 ${SRCRO ...
- API 的历史
原文出处: apievangelist 译文出处:灯下鼠 历史无处不在. 研究我们来自何方,有助于指引我们前行.科技的发展日新月异,但时常停一下匆忙的脚步,稍稍回顾一下历史,却总是有益的. 下面就 ...
- tdf sample
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...
- expdp指定时间戳导出防止数据不一致
expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp FLASHBACK_TIME=“TO_TIMESTAMP(’25-08-2004 14:35:00’,’ ...
- MySQL:数据库入门篇2
#移除主键时需要先解除递增,才能解除主键 alter table info modify id int null , drop PRIMARY key 一.用户权限 1.创建用户 create use ...