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

Side by Side Diff: base/synchronization/spin_wait.h

Issue 10735044: Remove #pragma once. Just from base/ for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/synchronization/lock_impl.h ('k') | base/synchronization/waitable_event.h » ('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 // 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.
11 11
12 // We provide a simple one argument spin wait (for 1 second), and a generic 12 // We provide a simple one argument spin wait (for 1 second), and a generic
13 // spin wait (for longer periods of time). 13 // spin wait (for longer periods of time).
14 14
15 #ifndef BASE_SYNCHRONIZATION_SPIN_WAIT_H_ 15 #ifndef BASE_SYNCHRONIZATION_SPIN_WAIT_H_
16 #define BASE_SYNCHRONIZATION_SPIN_WAIT_H_ 16 #define BASE_SYNCHRONIZATION_SPIN_WAIT_H_
17 #pragma once
18 17
19 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
20 #include "base/time.h" 19 #include "base/time.h"
21 20
22 // Provide a macro that will wait no longer than 1 second for an asynchronous 21 // Provide a macro that will wait no longer than 1 second for an asynchronous
23 // change is the value of an expression. 22 // change is the value of an expression.
24 // A typical use would be: 23 // A typical use would be:
25 // 24 //
26 // SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(0 == f(x)); 25 // SPIN_FOR_1_SECOND_OR_UNTIL_TRUE(0 == f(x));
27 // 26 //
(...skipping 14 matching lines...) Expand all
42 if (kTimeout < base::TimeTicks::Now() - start) { \ 41 if (kTimeout < base::TimeTicks::Now() - start) { \
43 EXPECT_LE((base::TimeTicks::Now() - start).InMilliseconds(), \ 42 EXPECT_LE((base::TimeTicks::Now() - start).InMilliseconds(), \
44 kTimeout.InMilliseconds()) << "Timed out"; \ 43 kTimeout.InMilliseconds()) << "Timed out"; \
45 break; \ 44 break; \
46 } \ 45 } \
47 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50)); \ 46 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50)); \
48 } \ 47 } \
49 } while (0) 48 } while (0)
50 49
51 #endif // BASE_SYNCHRONIZATION_SPIN_WAIT_H_ 50 #endif // BASE_SYNCHRONIZATION_SPIN_WAIT_H_
OLDNEW
« no previous file with comments | « base/synchronization/lock_impl.h ('k') | base/synchronization/waitable_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698