| OLD | NEW |
| 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 #include <windows.h> | 11 #include <windows.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #if defined(OS_POSIX) | 14 #if defined(OS_POSIX) |
| 15 #include <list> | 15 #include <list> |
| 16 #include <utility> | 16 #include <utility> |
| 17 #include "base/condition_variable.h" | 17 #include "base/condition_variable.h" |
| 18 #include "base/lock.h" | 18 #include "base/lock.h" |
| 19 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 | 25 |
| 26 // This replaces INFINITE from Win32 |
| 27 static const int kNoTimeout = -1; |
| 28 |
| 26 class TimeDelta; | 29 class TimeDelta; |
| 27 | 30 |
| 28 // A WaitableEvent can be a useful thread synchronization tool when you want to | 31 // A WaitableEvent can be a useful thread synchronization tool when you want to |
| 29 // allow one thread to wait for another thread to finish some work. For | 32 // allow one thread to wait for another thread to finish some work. For |
| 30 // non-Windows systems, this can only be used from within a single address | 33 // non-Windows systems, this can only be used from within a single address |
| 31 // space. | 34 // space. |
| 32 // | 35 // |
| 33 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to | 36 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to |
| 34 // protect a simple boolean value. However, if you find yourself using a | 37 // protect a simple boolean value. However, if you find yourself using a |
| 35 // WaitableEvent in conjunction with a Lock to wait for a more complex state | 38 // WaitableEvent in conjunction with a Lock to wait for a more complex state |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 const bool manual_reset_; | 147 const bool manual_reset_; |
| 145 std::list<Waiter*> waiters_; | 148 std::list<Waiter*> waiters_; |
| 146 #endif | 149 #endif |
| 147 | 150 |
| 148 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); | 151 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); |
| 149 }; | 152 }; |
| 150 | 153 |
| 151 } // namespace base | 154 } // namespace base |
| 152 | 155 |
| 153 #endif // BASE_WAITABLE_EVENT_H_ | 156 #endif // BASE_WAITABLE_EVENT_H_ |
| OLD | NEW |