主要用到TLS,首次进入gHaveTLS为false,锁保护说明此函数很多其他函数在调用。
通过if (pthread_key_create(&gTLS, threadDestructor) != 0),中threadDestructor(void *st)
调用IPCThreadState::IPCThreadState()创建IPCThreadState对象,并将对象的索引设置为gTLS。再次进入后通过gTLS获取到IPCThreadState对象。
 IPCThreadState* IPCThreadState::self()
{
if (gHaveTLS) {
restart:
const pthread_key_t k = gTLS;
IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k);
if (st) return st;
return new IPCThreadState;
} if (gShutdown) return NULL; pthread_mutex_lock(&gTLSMutex);
if (!gHaveTLS) {
if (pthread_key_create(&gTLS, threadDestructor) != ) {
pthread_mutex_unlock(&gTLSMutex);
return NULL;
}
gHaveTLS = true;
}
pthread_mutex_unlock(&gTLSMutex);
goto restart;
}

通pthread_setspecific(gTLS, this);gTLS与IPCThreadState对象关联了。

 IPCThreadState::IPCThreadState()
: mProcess(ProcessState::self()),
mMyThreadId(androidGetTid()),
mStrictModePolicy(),
mLastTransactionBinderFlags()
{
pthread_setspecific(gTLS, this);
clearCaller();
mIn.setDataCapacity();
mOut.setDataCapacity();
}

最新文章

  1. 2015-12-23-( dispaly:table的用法)
  2. textarea输入回车,前台jsp不回车问题解决
  3. Mvc4学习笔记一(Ajax.ActionLink)
  4. 想要学好JQuery看这里
  5. Oracle脚本笔记
  6. Java数据结构和算法之递归
  7. .NET Remoting学习笔记(一)概念
  8. 课题:如何培养自己的SEO资源
  9. CSS兼容性(IE和Firefox)技巧大全
  10. spark connect to Cassandra problem
  11. CodeForces 589D Boulevard (数学,相遇)
  12. apple mac 下使用机械键盘的办法,键盘映射工具软件,apple mac Mechanical keyboard
  13. 理解C# Lazy<T>
  14. JuliaSet&MandelBulb @ Maya&KK —— 4亿粒子的测试
  15. C# 操作电脑 关机 重启 注销 休止 休眠
  16. Putty以及adb网络调试
  17. 【windows】常用快捷键
  18. Leetcode_204_Count Primes
  19. 响应式菜单栏: bootstrap + jQuery
  20. 并查集 P3367 【模板】并查集

热门文章

  1. 牛客寒假算法基础集训营1B题
  2. python代码技术优化
  3. maven中scope属性有哪些
  4. Python语言学习:模块
  5. chromosome interaction mapping|cis- and trans-regulation|de novo|SRS|LRS|Haplotype blocks|linkage disequilibrium
  6. 903A. Hungry Student Problem#饥饿的学生(暴力&双层枚举)
  7. sha1和md5的区别
  8. 如何写JS库,JS库写法
  9. Matlab高级教程_第二篇:Matlab相见恨晚的模块_02_全局变量的妙用_遍历穿透
  10. EternalBlue永恒之蓝漏洞复现