blob: 9f0ef98100ec4011cdd0bb097182e2ef88d18273 (
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
29
30
31
32
33
34
35
|
#ifndef PROCESS_ID_INL_H_
#error "Direct inclusion of this file is not allowed, include process_id.h"
// For the sake of sane code completion.
#include "process_id.h"
#endif
#include <atomic>
#include <util/system/compiler.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
namespace NDetail {
TProcessId GetProcessIdImpl();
} // namespace NDetail
extern std::atomic<TProcessId> CachedProcessId;
inline TProcessId GetProcessId()
{
auto cachedProcessId = CachedProcessId.load(std::memory_order::relaxed);
if (cachedProcessId == InvalidProcessId) [[unlikely]] {
cachedProcessId = NDetail::GetProcessIdImpl();
CachedProcessId.store(cachedProcessId, std::memory_order::relaxed);
}
return cachedProcessId;
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|