mudo CurrentThread详解

1. 简介

该模块为当前线程工具类

2. 类与接口

__thread int t_cachedTid; //线程id唯一标识
__thread char t_tidString[32]; //线程id唯一标识字符串形式
__thread int t_tidStringLength; //线程id唯一标识字符串形式长度
__thread const char* t_threadName; //当前线程名

_thread变量每一个线程有一份独立实体,各个线程的值互不干扰

① void cacheTid()
若当前tid为空,则初始化当前线程信息

② int tid()
获取线程id唯一标识

③ const char* tidString()
获取tid字符串形式

④ int tidStringLength()
获取tid字符串长度

⑤ const char* name()
获取线程名

⑥ bool isMainThread()
判断是否是主进程

⑦ void sleepUsec(int64_t usec)
微妙级睡眠

⑧ string stackTrace(bool demangle)
获取堆栈信息,demangle决定是否要进行源程序标识符的转换

3. 源码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值