Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: base/debug/activity_tracker_unittest.cc

Issue 2422683002: Hold allocator lock while fetching 'used' count. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/debug/activity_analyzer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/activity_tracker.h" 5 #include "base/debug/activity_tracker.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (!global_tracker) 67 if (!global_tracker)
68 return 0; 68 return 0;
69 return global_tracker->thread_tracker_count_.load( 69 return global_tracker->thread_tracker_count_.load(
70 std::memory_order_relaxed); 70 std::memory_order_relaxed);
71 } 71 }
72 72
73 size_t GetGlobalInactiveTrackerCount() { 73 size_t GetGlobalInactiveTrackerCount() {
74 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get(); 74 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get();
75 if (!global_tracker) 75 if (!global_tracker)
76 return 0; 76 return 0;
77 base::AutoLock autolock(global_tracker->thread_tracker_allocator_lock_);
77 return global_tracker->thread_tracker_allocator_.cache_used(); 78 return global_tracker->thread_tracker_allocator_.cache_used();
78 } 79 }
79 80
80 static void DoNothing() {} 81 static void DoNothing() {}
81 }; 82 };
82 83
83 TEST_F(ActivityTrackerTest, PushPopTest) { 84 TEST_F(ActivityTrackerTest, PushPopTest) {
84 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker(); 85 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker();
85 ActivitySnapshot snapshot; 86 ActivitySnapshot snapshot;
86 87
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount()); 282 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount());
282 283
283 t2.Exit(); 284 t2.Exit();
284 t2.Join(); 285 t2.Join();
285 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount()); 286 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount());
286 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount()); 287 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount());
287 } 288 }
288 289
289 } // namespace debug 290 } // namespace debug
290 } // namespace base 291 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_analyzer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698