blob: 86d34ef8a0e1ede4aac7c7b0b6eb608d94c4e154 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#ifndef THREAD_ID_INL_H_
#error "Direct inclusion of this file is not allowed, include thread_id.h"
// For the sake of sane code completion.
#include "thread_id.h"
#endif
#include <atomic>
#include <util/system/compiler.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
extern thread_local TSequentialThreadId CachedSequentialThreadId;
extern std::atomic<TSequentialThreadId> SequentialThreadIdGenerator;
inline TSequentialThreadId GetSequentialThreadId()
{
if (Y_UNLIKELY(CachedSequentialThreadId == InvalidSequentialThreadId)) {
CachedSequentialThreadId = ++SequentialThreadIdGenerator;
}
return CachedSequentialThreadId;
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|