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

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

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| Created 6 years 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 } 84 }
85 85
86 private: 86 private:
87 static void SleepALittle() { 87 static void SleepALittle() {
88 static const long kNanosPerMilli = 1000000; 88 static const long kNanosPerMilli = 1000000;
89 struct timespec req = { 89 struct timespec req = {
90 0, // Seconds. 90 0, // Seconds.
91 (rand() % 10) * kNanosPerMilli // Nanoseconds. 91 (rand() % 10) * kNanosPerMilli // Nanoseconds.
92 }; 92 };
93 int rv = nanosleep(&req, NULL); 93 int rv = nanosleep(&req, nullptr);
94 MOJO_ALLOW_UNUSED_LOCAL(rv); 94 MOJO_ALLOW_UNUSED_LOCAL(rv);
95 assert(rv == 0); 95 assert(rv == 0);
96 } 96 }
97 97
98 const size_t times_to_lock_; 98 const size_t times_to_lock_;
99 const Type type_; 99 const Type type_;
100 const bool should_sleep_; 100 const bool should_sleep_;
101 Mutex* const mutex_; 101 Mutex* const mutex_;
102 int* const shared_value_; 102 int* const shared_value_;
103 103
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Destroy lock with lock held. 250 // Destroy lock with lock held.
251 EXPECT_DEATH_IF_SUPPORTED({ 251 EXPECT_DEATH_IF_SUPPORTED({
252 Mutex mutex; 252 Mutex mutex;
253 mutex.Lock(); 253 mutex.Lock();
254 }, ""); 254 }, "");
255 } 255 }
256 #endif // !defined(NDEBUG) 256 #endif // !defined(NDEBUG)
257 257
258 } // namespace 258 } // namespace
259 } // namespace mojo 259 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698