LSSTApplications  18.0.0+46,18.0.0+95,19.0.0,19.0.0+1,19.0.0+2,19.0.0+4,19.0.0+5,19.0.0+6,19.0.0-1-g20d9b18+2,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+2,19.0.0-1-g5db401e+5,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+4,19.0.0-1-g8c57eb9+2,19.0.0-1-gb5175dc+4,19.0.0-1-gd7f3e1b+4,19.0.0-1-gdc0e4a7+4,19.0.0-1-ge272bc4+2,19.0.0-1-gf46fa72,19.0.0-2-g0d9f9cd+4,19.0.0-2-g1c703f9ef+1,19.0.0-2-g3d9e4fb2+4,19.0.0-2-gd955cfd+4,19.0.0-2-gdbc0a5a+1,19.0.0-3-g2d13df8,19.0.0-3-g3c38ad5,19.0.0-4-g725f80e,19.0.0-7-gf796fef9+5,19.0.0-8-g608b899+1,w.2019.49
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 }