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

Side by Side Diff: base/spin_wait.h

Issue 9055001: Change code in base (primarily unit tests) to use Sleep(TimeDelta). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Qualify windows Sleep calls to go through PlatformThread. Created 8 years, 11 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/shared_memory_unittest.cc ('k') | base/synchronization/condition_variable_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file provides a macro ONLY for use in testing. 5 // This file provides a macro ONLY for use in testing.
6 // DO NOT USE IN PRODUCTION CODE. There are much better ways to wait. 6 // DO NOT USE IN PRODUCTION CODE. There are much better ways to wait.
7 7
8 // This code is very helpful in testing multi-threaded code, without depending 8 // This code is very helpful in testing multi-threaded code, without depending
9 // on almost any primitives. This is especially helpful if you are testing 9 // on almost any primitives. This is especially helpful if you are testing
10 // those primitive multi-threaded constructs. 10 // those primitive multi-threaded constructs.
(...skipping 26 matching lines...) Expand all
37 37
38 #define SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(delta, expression) do { \ 38 #define SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(delta, expression) do { \
39 base::TimeTicks start = base::TimeTicks::Now(); \ 39 base::TimeTicks start = base::TimeTicks::Now(); \
40 const base::TimeDelta kTimeout = delta; \ 40 const base::TimeDelta kTimeout = delta; \
41 while (!(expression)) { \ 41 while (!(expression)) { \
42 if (kTimeout < base::TimeTicks::Now() - start) { \ 42 if (kTimeout < base::TimeTicks::Now() - start) { \
43 EXPECT_LE((base::TimeTicks::Now() - start).InMilliseconds(), \ 43 EXPECT_LE((base::TimeTicks::Now() - start).InMilliseconds(), \
44 kTimeout.InMilliseconds()) << "Timed out"; \ 44 kTimeout.InMilliseconds()) << "Timed out"; \
45 break; \ 45 break; \
46 } \ 46 } \
47 base::PlatformThread::Sleep(50); \ 47 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50)); \
48 } \ 48 } \
49 } while (0) 49 } while (0)
50 50
51 #endif // BASE_SPIN_WAIT_H_ 51 #endif // BASE_SPIN_WAIT_H_
OLDNEW
« no previous file with comments | « base/shared_memory_unittest.cc ('k') | base/synchronization/condition_variable_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698