File tree Expand file tree Collapse file tree 2 files changed +1
-12
lines changed
Expand file tree Collapse file tree 2 files changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -385,13 +385,7 @@ class V8_BASE_EXPORT Thread {
385385 static LocalStorageKey CreateThreadLocalKey ();
386386 static void DeleteThreadLocalKey (LocalStorageKey key);
387387 static void * GetThreadLocal (LocalStorageKey key);
388- static int GetThreadLocalInt (LocalStorageKey key) {
389- return static_cast <int >(reinterpret_cast <intptr_t >(GetThreadLocal (key)));
390- }
391388 static void SetThreadLocal (LocalStorageKey key, void * value);
392- static void SetThreadLocalInt (LocalStorageKey key, int value) {
393- SetThreadLocal (key, reinterpret_cast <void *>(static_cast <intptr_t >(value)));
394- }
395389 static bool HasThreadLocal (LocalStorageKey key) {
396390 return GetThreadLocal (key) != nullptr ;
397391 }
Original file line number Diff line number Diff line change @@ -11,27 +11,22 @@ namespace internal {
1111
1212namespace {
1313
14- DEFINE_LAZY_LEAKY_OBJECT_GETTER (base::Thread::LocalStorageKey, GetThreadIdKey,
15- base::Thread::CreateThreadLocalKey ())
14+ thread_local int thread_id = 0 ;
1615
1716std::atomic<int > next_thread_id{1 };
1817
1918} // namespace
2019
2120// static
2221ThreadId ThreadId::TryGetCurrent () {
23- int thread_id = base::Thread::GetThreadLocalInt (*GetThreadIdKey ());
2422 return thread_id == 0 ? Invalid () : ThreadId (thread_id);
2523}
2624
2725// static
2826int ThreadId::GetCurrentThreadId () {
29- auto key = *GetThreadIdKey ();
30- int thread_id = base::Thread::GetThreadLocalInt (key);
3127 if (thread_id == 0 ) {
3228 thread_id = next_thread_id.fetch_add (1 );
3329 CHECK_LE (1 , thread_id);
34- base::Thread::SetThreadLocalInt (key, thread_id);
3530 }
3631 return thread_id;
3732}
You can’t perform that action at this time.
0 commit comments