mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
15 lines
298 B
C++
15 lines
298 B
C++
#include <common/getThreadNumber.h>
|
|
#include <common/likely.h>
|
|
#include <atomic>
|
|
|
|
static thread_local unsigned thread_number = 0;
|
|
static std::atomic_uint threads{0};
|
|
|
|
unsigned getThreadNumber()
|
|
{
|
|
if (unlikely(thread_number == 0))
|
|
thread_number = ++threads;
|
|
|
|
return thread_number;
|
|
}
|