diff --git a/libs/libcommon/src/ThreadNumber.cpp b/libs/libcommon/src/ThreadNumber.cpp new file mode 100644 index 00000000000..05cd4211921 --- /dev/null +++ b/libs/libcommon/src/ThreadNumber.cpp @@ -0,0 +1,12 @@ +#include + + +__thread unsigned thread_number = 0; +unsigned threads = 0; + +unsigned ThreadNumber::get() +{ + if (unlikely(!thread_number)) + thread_number = __sync_add_and_fetch(&threads, 1); + return thread_number; +}