MCPcopy Create free account
hub / github.com/ByConity/ByConity / getThreadId

Function getThreadId

base/common/getThreadId.cpp:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17static thread_local uint64_t current_tid = 0;
18uint64_t getThreadId()
19{
20 if (!current_tid)
21 {
22#if defined(OS_ANDROID)
23 current_tid = gettid();
24#elif defined(OS_LINUX)
25 current_tid = syscall(SYS_gettid); /// This call is always successful. - man gettid
26#elif defined(OS_FREEBSD)
27 current_tid = pthread_getthreadid_np();
28#elif defined(OS_SUNOS)
29 // On Solaris-derived systems, this returns the ID of the LWP, analogous
30 // to a thread.
31 current_tid = static_cast<uint64_t>(pthread_self());
32#else
33 if (0 != pthread_threadid_np(nullptr, &current_tid))
34 throw std::logic_error("pthread_threadid_np returned error");
35#endif
36 }
37
38 return current_tid;
39}

Callers 15

dumpCallbackErrorFunction · 0.85
signalHandlerFunction · 0.85
sanitizerDeathCallbackFunction · 0.85
terminate_handlerFunction · 0.85
getFromMethod · 0.85
writeMethod · 0.85
setToLoadingMethod · 0.85
MergeListElementMethod · 0.85
ThreadStatusMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected