diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-08-01 08:38:30 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-08-01 12:53:56 +0200 |
commit | 2dcc3665abf57c3607cebffdeeca062f5894885d (patch) | |
tree | 4f560748132edcfb4c22d6f967a7e80d23d7ea2c /deps/v8/src/execution/thread-id.h | |
parent | 1ee47d550c6de132f06110aa13eceb7551d643b3 (diff) | |
download | android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.gz android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.bz2 android-node-v8-2dcc3665abf57c3607cebffdeeca062f5894885d.zip |
deps: update V8 to 7.6.303.28
PR-URL: https://github.com/nodejs/node/pull/28016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps/v8/src/execution/thread-id.h')
-rw-r--r-- | deps/v8/src/execution/thread-id.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/deps/v8/src/execution/thread-id.h b/deps/v8/src/execution/thread-id.h new file mode 100644 index 0000000000..27f05843f3 --- /dev/null +++ b/deps/v8/src/execution/thread-id.h @@ -0,0 +1,54 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_EXECUTION_THREAD_ID_H_ +#define V8_EXECUTION_THREAD_ID_H_ + +#include "src/base/macros.h" + +namespace v8 { +namespace internal { + +// Platform-independent, reliable thread identifier. +class ThreadId { + public: + // Creates an invalid ThreadId. + constexpr ThreadId() noexcept : ThreadId(kInvalidId) {} + + bool operator==(const ThreadId& other) const { return id_ == other.id_; } + bool operator!=(const ThreadId& other) const { return id_ != other.id_; } + + // Checks whether this ThreadId refers to any thread. + bool IsValid() const { return id_ != kInvalidId; } + + // Converts ThreadId to an integer representation. + constexpr int ToInteger() const { return id_; } + + // Returns ThreadId for current thread if it exists or invalid id. + static ThreadId TryGetCurrent(); + + // Returns ThreadId for current thread. + static ThreadId Current() { return ThreadId(GetCurrentThreadId()); } + + // Returns invalid ThreadId (guaranteed not to be equal to any thread). + static constexpr ThreadId Invalid() { return ThreadId(kInvalidId); } + + // Converts ThreadId to an integer representation + // (required for public API: V8::V8::TerminateExecution). + static constexpr ThreadId FromInteger(int id) { return ThreadId(id); } + + private: + static constexpr int kInvalidId = -1; + + explicit constexpr ThreadId(int id) noexcept : id_(id) {} + + V8_EXPORT_PRIVATE static int GetCurrentThreadId(); + + int id_; +}; + +} // namespace internal +} // namespace v8 + +#endif // V8_EXECUTION_THREAD_ID_H_ |