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

Side by Side Diff: base/waitable_event.h

Issue 7995: Move Time, TimeDelta and TimeTicks into namespace base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef BASE_WAITABLE_EVENT_H_ 5 #ifndef BASE_WAITABLE_EVENT_H_
6 #define BASE_WAITABLE_EVENT_H_ 6 #define BASE_WAITABLE_EVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 typedef void* HANDLE; 11 typedef void* HANDLE;
12 #else 12 #else
13 #include "base/condition_variable.h" 13 #include "base/condition_variable.h"
14 #include "base/lock.h" 14 #include "base/lock.h"
15 #endif 15 #endif
16 16
17 namespace base {
18
17 class TimeDelta; 19 class TimeDelta;
18 20
19 namespace base {
20
21 // A WaitableEvent can be a useful thread synchronization tool when you want to 21 // A WaitableEvent can be a useful thread synchronization tool when you want to
22 // allow one thread to wait for another thread to finish some work. 22 // allow one thread to wait for another thread to finish some work.
23 // 23 //
24 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to 24 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to
25 // protect a simple boolean value. However, if you find yourself using a 25 // protect a simple boolean value. However, if you find yourself using a
26 // WaitableEvent in conjunction with a Lock to wait for a more complex state 26 // WaitableEvent in conjunction with a Lock to wait for a more complex state
27 // change (e.g., for an item to be added to a queue), then you should probably 27 // change (e.g., for an item to be added to a queue), then you should probably
28 // be using a ConditionVariable instead of a WaitableEvent. 28 // be using a ConditionVariable instead of a WaitableEvent.
29 // 29 //
30 // NOTE: On Windows, this class provides a subset of the functionality afforded 30 // NOTE: On Windows, this class provides a subset of the functionality afforded
(...skipping 24 matching lines...) Expand all
55 // is not a manual reset event, then this test will cause a reset. 55 // is not a manual reset event, then this test will cause a reset.
56 bool IsSignaled(); 56 bool IsSignaled();
57 57
58 // Wait indefinitely for the event to be signaled. Returns true if the event 58 // Wait indefinitely for the event to be signaled. Returns true if the event
59 // was signaled, else false is returned to indicate that waiting failed. 59 // was signaled, else false is returned to indicate that waiting failed.
60 bool Wait(); 60 bool Wait();
61 61
62 // Wait up until max_time has passed for the event to be signaled. Returns 62 // Wait up until max_time has passed for the event to be signaled. Returns
63 // true if the event was signaled. If this method returns false, then it 63 // true if the event was signaled. If this method returns false, then it
64 // does not necessarily mean that max_time was exceeded. 64 // does not necessarily mean that max_time was exceeded.
65 bool TimedWait(const TimeDelta& max_time); 65 bool TimedWait(const base::TimeDelta& max_time);
brettw 2008/10/24 23:47:52 You don't need this one either.
66 66
67 private: 67 private:
68 #if defined(OS_WIN) 68 #if defined(OS_WIN)
69 HANDLE event_; 69 HANDLE event_;
70 #else 70 #else
71 Lock lock_; // Needs to be listed first so it will be constructed first. 71 Lock lock_; // Needs to be listed first so it will be constructed first.
72 ConditionVariable cvar_; 72 ConditionVariable cvar_;
73 bool signaled_; 73 bool signaled_;
74 bool manual_reset_; 74 bool manual_reset_;
75 #endif 75 #endif
76 76
77 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); 77 DISALLOW_COPY_AND_ASSIGN(WaitableEvent);
78 }; 78 };
79 79
80 } // namespace base 80 } // namespace base
81 81
82 #endif // BASE_WAITABLE_EVENT_H_ 82 #endif // BASE_WAITABLE_EVENT_H_
83
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698