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

Side by Side Diff: base/threading/thread_unittest.cc

Issue 2032603002: Migrate WaitableEvent to enum-based constructor in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: undo incorrect template change Created 4 years, 6 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/threading/thread_perftest.cc ('k') | base/threading/worker_pool_posix_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/threading/thread.h" 5 #include "base/threading/thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 EXPECT_EQ("ThreadName", a.thread_name()); 207 EXPECT_EQ("ThreadName", a.thread_name());
208 } 208 }
209 209
210 TEST_F(ThreadTest, ThreadId) { 210 TEST_F(ThreadTest, ThreadId) {
211 Thread a("ThreadId0"); 211 Thread a("ThreadId0");
212 Thread b("ThreadId1"); 212 Thread b("ThreadId1");
213 a.Start(); 213 a.Start();
214 b.Start(); 214 b.Start();
215 215
216 // Post a task that calls GetThreadId() on the created thread. 216 // Post a task that calls GetThreadId() on the created thread.
217 base::WaitableEvent event(false, false); 217 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
218 base::WaitableEvent::InitialState::NOT_SIGNALED);
218 base::PlatformThreadId id_from_new_thread; 219 base::PlatformThreadId id_from_new_thread;
219 a.task_runner()->PostTask( 220 a.task_runner()->PostTask(
220 FROM_HERE, base::Bind(ReturnThreadId, &a, &id_from_new_thread, &event)); 221 FROM_HERE, base::Bind(ReturnThreadId, &a, &id_from_new_thread, &event));
221 222
222 // Call GetThreadId() on the current thread before calling event.Wait() so 223 // Call GetThreadId() on the current thread before calling event.Wait() so
223 // that this test can find a race issue with TSAN. 224 // that this test can find a race issue with TSAN.
224 base::PlatformThreadId id_from_current_thread = a.GetThreadId(); 225 base::PlatformThreadId id_from_current_thread = a.GetThreadId();
225 226
226 // Check if GetThreadId() returns consistent value in both threads. 227 // Check if GetThreadId() returns consistent value in both threads.
227 event.Wait(); 228 event.Wait();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 EXPECT_FALSE(a.task_runner()); 295 EXPECT_FALSE(a.task_runner());
295 } 296 }
296 297
297 TEST_F(ThreadTest, MultipleWaitUntilThreadStarted) { 298 TEST_F(ThreadTest, MultipleWaitUntilThreadStarted) {
298 Thread a("MultipleWaitUntilThreadStarted"); 299 Thread a("MultipleWaitUntilThreadStarted");
299 EXPECT_TRUE(a.Start()); 300 EXPECT_TRUE(a.Start());
300 // It's OK to call WaitUntilThreadStarted() multiple times. 301 // It's OK to call WaitUntilThreadStarted() multiple times.
301 EXPECT_TRUE(a.WaitUntilThreadStarted()); 302 EXPECT_TRUE(a.WaitUntilThreadStarted());
302 EXPECT_TRUE(a.WaitUntilThreadStarted()); 303 EXPECT_TRUE(a.WaitUntilThreadStarted());
303 } 304 }
OLDNEW
« no previous file with comments | « base/threading/thread_perftest.cc ('k') | base/threading/worker_pool_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698