| 1 | #include <common/getThreadNumber.h> |
|---|---|
| 2 | #include <common/likely.h> |
| 3 | #include <atomic> |
| 4 | |
| 5 | static thread_local unsigned thread_number = 0; |
| 6 | static std::atomic_uint threads{0}; |
| 7 | |
| 8 | unsigned getThreadNumber() |
| 9 | { |
| 10 | if (unlikely(thread_number == 0)) |
| 11 | thread_number = ++threads; |
| 12 | |
| 13 | return thread_number; |
| 14 | } |
| 15 |