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

Side by Side Diff: base/threading/thread_local_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.cc ('k') | base/threading/thread_perftest.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/logging.h" 5 #include "base/logging.h"
6 #include "base/threading/simple_thread.h" 6 #include "base/threading/simple_thread.h"
7 #include "base/threading/thread_local.h" 7 #include "base/threading/thread_local.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 base::DelegateSimpleThreadPool tp1("ThreadLocalTest tp1", 1); 75 base::DelegateSimpleThreadPool tp1("ThreadLocalTest tp1", 1);
76 base::DelegateSimpleThreadPool tp2("ThreadLocalTest tp1", 1); 76 base::DelegateSimpleThreadPool tp2("ThreadLocalTest tp1", 1);
77 tp1.Start(); 77 tp1.Start();
78 tp2.Start(); 78 tp2.Start();
79 79
80 base::ThreadLocalPointer<char> tlp; 80 base::ThreadLocalPointer<char> tlp;
81 81
82 static char* const kBogusPointer = reinterpret_cast<char*>(0x1234); 82 static char* const kBogusPointer = reinterpret_cast<char*>(0x1234);
83 83
84 char* tls_val; 84 char* tls_val;
85 base::WaitableEvent done(true, false); 85 base::WaitableEvent done(WaitableEvent::ResetPolicy::MANUAL,
86 WaitableEvent::InitialState::NOT_SIGNALED);
86 87
87 GetThreadLocal getter(&tlp, &done); 88 GetThreadLocal getter(&tlp, &done);
88 getter.set_ptr(&tls_val); 89 getter.set_ptr(&tls_val);
89 90
90 // Check that both threads defaulted to NULL. 91 // Check that both threads defaulted to NULL.
91 tls_val = kBogusPointer; 92 tls_val = kBogusPointer;
92 done.Reset(); 93 done.Reset();
93 tp1.AddWork(&getter); 94 tp1.AddWork(&getter);
94 done.Wait(); 95 done.Wait();
95 EXPECT_EQ(static_cast<char*>(NULL), tls_val); 96 EXPECT_EQ(static_cast<char*>(NULL), tls_val);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 // Our slot should have been freed, we're all reset. 162 // Our slot should have been freed, we're all reset.
162 { 163 {
163 base::ThreadLocalBoolean tlb; 164 base::ThreadLocalBoolean tlb;
164 EXPECT_FALSE(tlb.Get()); 165 EXPECT_FALSE(tlb.Get());
165 } 166 }
166 } 167 }
167 168
168 } // namespace base 169 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread.cc ('k') | base/threading/thread_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698