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
5
#include "
src/execution/thread-id.h
"
6
#include "
src/base/lazy-instance.h
"
7
#include "
src/base/platform/platform.h
"
8
9
namespace
v8
{
10
namespace
internal
{
11
12
namespace
{
13
14
thread_local
int
thread_id = 0;
15
16
std::atomic<int> next_thread_id{1};
17
18
}
// namespace
19
20
// static
21
ThreadId
ThreadId::TryGetCurrent
() {
22
return
thread_id == 0 ?
Invalid
() :
ThreadId
(thread_id);
23
}
24
25
// static
26
int
ThreadId::GetCurrentThreadId
() {
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
v8::internal::ThreadId
Definition
thread-id.h:14
v8::internal::ThreadId::TryGetCurrent
static ThreadId TryGetCurrent()
Definition
thread-id.cc:21
v8::internal::ThreadId::GetCurrentThreadId
static V8_EXPORT_PRIVATE int GetCurrentThreadId()
Definition
thread-id.cc:26
v8::internal::ThreadId::Invalid
static constexpr ThreadId Invalid()
Definition
thread-id.h:35
v8::internal::ThreadId::ThreadId
constexpr ThreadId() noexcept
Definition
thread-id.h:17
lazy-instance.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
CHECK_LE
#define CHECK_LE(lhs, rhs)
platform.h
thread-id.h
src
execution
thread-id.cc
Generated on Sun Apr 6 2025 21:08:53 for v8 by
1.12.0