OLD | NEW |
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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const int kNumThreads = 32; | 123 const int kNumThreads = 32; |
124 std::unique_ptr<Thread> threads[kNumThreads]; | 124 std::unique_ptr<Thread> threads[kNumThreads]; |
125 for (int i = 0; i < kNumThreads; i++) { | 125 for (int i = 0; i < kNumThreads; i++) { |
126 threads[i].reset(new Thread("test thread")); | 126 threads[i].reset(new Thread("test thread")); |
127 threads[i]->Start(); | 127 threads[i]->Start(); |
128 } | 128 } |
129 WaitableEvent sync_event(WaitableEvent::ResetPolicy::MANUAL, | 129 WaitableEvent sync_event(WaitableEvent::ResetPolicy::MANUAL, |
130 WaitableEvent::InitialState::NOT_SIGNALED); | 130 WaitableEvent::InitialState::NOT_SIGNALED); |
131 for (int i = 0; i < kNumThreads; i++) { | 131 for (int i = 0; i < kNumThreads; i++) { |
132 threads[i]->task_runner()->PostTask( | 132 threads[i]->task_runner()->PostTask( |
133 FROM_HERE, Bind(&TestRaceThreadMain, Unretained(&sync_event))); | 133 FROM_HERE, BindOnce(&TestRaceThreadMain, Unretained(&sync_event))); |
134 } | 134 } |
135 sync_event.Signal(); | 135 sync_event.Signal(); |
136 for (int i = 0; i < kNumThreads; i++) | 136 for (int i = 0; i < kNumThreads; i++) |
137 threads[i]->Stop(); | 137 threads[i]->Stop(); |
138 | 138 |
139 int num_times_seen = 0; | 139 int num_times_seen = 0; |
140 for (const TraceCategory& cat : GetAllCategories()) { | 140 for (const TraceCategory& cat : GetAllCategories()) { |
141 if (strcmp(cat.name(), "__test_race") == 0) | 141 if (strcmp(cat.name(), "__test_race") == 0) |
142 num_times_seen++; | 142 num_times_seen++; |
143 } | 143 } |
144 ASSERT_EQ(1, num_times_seen); | 144 ASSERT_EQ(1, num_times_seen); |
145 } | 145 } |
146 | 146 |
147 } // namespace trace_event | 147 } // namespace trace_event |
148 } // namespace base | 148 } // namespace base |
OLD | NEW |