https://blog.csdn.net/shuimuniao/article/details/8017971
#define LIKELY(x) __builtin_expect(!!(x), 1) //x很可能为真 #define UNLIKELY(x) __builtin_expect(!!(x), 0) //x很可能为假
CurrentThread.h
namespace CurrentThread { // internal extern __thread int t_cachedTid; extern __thread char t_tidString[32]; extern __thread int t_tidStringLength; extern __thread const char* t_threadName; void cacheTid(); inline int tid() { if (__builtin_expect(t_cachedTid == 0, 0)) { cacheTid(); } return t_cachedTid; } inline const char* tidString() // for logging { return t_tidString; } inline int tidStringLength() // for logging { return t_tidStringLength; } inline const char* name() { return t_threadName; } }