summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system/thread_id.h
blob: 75960d036e12e064f78aa5a33b21460bfa3e33cb (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
#pragma once

#include <util/generic/ylimits.h>

#include <util/system/types.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

using TSystemThreadId = size_t;
constexpr TSystemThreadId InvalidSystemThreadId = Max<TSystemThreadId>();
//! Returns the OS thread id (e.g. |gettid| on Linux).
//! The value is cached in TLS, so only the first call per thread hits the kernel.
//! The cache is reset in the child after |fork|.
TSystemThreadId GetSystemThreadId();

using TSequentialThreadId = ui32;
constexpr TSequentialThreadId InvalidSequentialThreadId = Max<TSequentialThreadId>();
TSequentialThreadId GetSequentialThreadId();

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define THREAD_ID_INL_H_
#include "thread_id-inl.h"
#undef THREAD_ID_INL_H_