LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Functions
lsst::log::detail Namespace Reference

Functions

unsigned lwpID ()
 

Function Documentation

◆ lwpID()

unsigned lsst::log::detail::lwpID ( )

Definition at line 40 of file lwpID.cc.

40  {
41 
42 #if defined(__linux__)
43 
44  // On Linux have to do syscall
45  auto lwp = syscall(SYS_gettid);
46 
47 #elif defined(__APPLE__)
48 
49  // OSX has a special Pthreads function to find out PID
50  auto lwp = pthread_mach_thread_np(pthread_self());
51 
52 #else
53 
54  // On all other system just generate incremental number and call it LWP
55  static std::atomic<unsigned> threadNum(0);
56  thread_local static auto lwp = ++threadNum;
57 
58 #endif
59 
60  return static_cast<unsigned>(lwp);
61 }
std::atomic
STL class.