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

Side by Side Diff: mojo/public/cpp/utility/tests/mutex_unittest.cc

Issue 617503003: Mojo: MOJO_OVERRIDE -> override in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/public/cpp/utility/mutex.h" 5 #include "mojo/public/cpp/utility/mutex.h"
6 6
7 #include <stdlib.h> // For |rand()|. 7 #include <stdlib.h> // For |rand()|.
8 #include <time.h> // For |nanosleep()| (defined by POSIX). 8 #include <time.h> // For |nanosleep()| (defined by POSIX).
9 9
10 #include <vector> 10 #include <vector>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 public: 107 public:
108 // Takes ownership of |fiddler|. 108 // Takes ownership of |fiddler|.
109 FiddlerThread(Fiddler* fiddler) 109 FiddlerThread(Fiddler* fiddler)
110 : fiddler_(fiddler) { 110 : fiddler_(fiddler) {
111 } 111 }
112 112
113 virtual ~FiddlerThread() { 113 virtual ~FiddlerThread() {
114 delete fiddler_; 114 delete fiddler_;
115 } 115 }
116 116
117 virtual void Run() MOJO_OVERRIDE { 117 virtual void Run() override { fiddler_->Fiddle(); }
118 fiddler_->Fiddle();
119 }
120 118
121 private: 119 private:
122 Fiddler* const fiddler_; 120 Fiddler* const fiddler_;
123 121
124 MOJO_DISALLOW_COPY_AND_ASSIGN(FiddlerThread); 122 MOJO_DISALLOW_COPY_AND_ASSIGN(FiddlerThread);
125 }; 123 };
126 124
127 // This does a stress test (that also checks exclusion). 125 // This does a stress test (that also checks exclusion).
128 TEST(MutexTest, ThreadedStress) { 126 TEST(MutexTest, ThreadedStress) {
129 static const size_t kNumThreads = 20; 127 static const size_t kNumThreads = 20;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 for (size_t i = 0; i < kNumThreads; i++) 161 for (size_t i = 0; i < kNumThreads; i++)
164 delete fiddler_threads[i]; 162 delete fiddler_threads[i];
165 fiddler_threads.clear(); 163 fiddler_threads.clear();
166 } 164 }
167 165
168 class TryThread : public Thread { 166 class TryThread : public Thread {
169 public: 167 public:
170 explicit TryThread(Mutex* mutex) : mutex_(mutex), try_lock_succeeded_() {} 168 explicit TryThread(Mutex* mutex) : mutex_(mutex), try_lock_succeeded_() {}
171 virtual ~TryThread() {} 169 virtual ~TryThread() {}
172 170
173 virtual void Run() MOJO_OVERRIDE { 171 virtual void Run() override {
174 try_lock_succeeded_ = mutex_->TryLock(); 172 try_lock_succeeded_ = mutex_->TryLock();
175 if (try_lock_succeeded_) 173 if (try_lock_succeeded_)
176 mutex_->Unlock(); 174 mutex_->Unlock();
177 } 175 }
178 176
179 bool try_lock_succeeded() const { return try_lock_succeeded_; } 177 bool try_lock_succeeded() const { return try_lock_succeeded_; }
180 178
181 private: 179 private:
182 Mutex* const mutex_; 180 Mutex* const mutex_;
183 bool try_lock_succeeded_; 181 bool try_lock_succeeded_;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Destroy lock with lock held. 251 // Destroy lock with lock held.
254 EXPECT_DEATH_IF_SUPPORTED({ 252 EXPECT_DEATH_IF_SUPPORTED({
255 Mutex mutex; 253 Mutex mutex;
256 mutex.Lock(); 254 mutex.Lock();
257 }, ""); 255 }, "");
258 } 256 }
259 #endif // !defined(NDEBUG) 257 #endif // !defined(NDEBUG)
260 258
261 } // namespace 259 } // namespace
262 } // namespace mojo 260 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/tests/macros_unittest.cc ('k') | mojo/public/cpp/utility/tests/run_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698