v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
thread-id.cc
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
8
9namespace v8 {
10namespace internal {
11
12namespace {
13
14thread_local int thread_id = 0;
15
16std::atomic<int> next_thread_id{1};
17
18} // namespace
19
20// static
22 return thread_id == 0 ? Invalid() : ThreadId(thread_id);
23}
24
25// static
27 if (thread_id == 0) {
28 thread_id = next_thread_id.fetch_add(1);
29 CHECK_LE(1, thread_id);
30 }
31 return thread_id;
32}
33
34} // namespace internal
35} // namespace v8
static ThreadId TryGetCurrent()
Definition thread-id.cc:21
static V8_EXPORT_PRIVATE int GetCurrentThreadId()
Definition thread-id.cc:26
static constexpr ThreadId Invalid()
Definition thread-id.h:35
constexpr ThreadId() noexcept
Definition thread-id.h:17
#define CHECK_LE(lhs, rhs)