OLD | NEW |
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 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 5 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // WaitableEvent in conjunction with a Lock to wait for a more complex state | 36 // WaitableEvent in conjunction with a Lock to wait for a more complex state |
37 // change (e.g., for an item to be added to a queue), then you should probably | 37 // change (e.g., for an item to be added to a queue), then you should probably |
38 // be using a ConditionVariable instead of a WaitableEvent. | 38 // be using a ConditionVariable instead of a WaitableEvent. |
39 // | 39 // |
40 // NOTE: On Windows, this class provides a subset of the functionality afforded | 40 // NOTE: On Windows, this class provides a subset of the functionality afforded |
41 // by a Windows event object. This is intentional. If you are writing Windows | 41 // by a Windows event object. This is intentional. If you are writing Windows |
42 // specific code and you need other features of a Windows event, then you might | 42 // specific code and you need other features of a Windows event, then you might |
43 // be better off just using an Windows event directly. | 43 // be better off just using an Windows event directly. |
44 class BASE_EXPORT WaitableEvent { | 44 class BASE_EXPORT WaitableEvent { |
45 public: | 45 public: |
| 46 // Indicates whether a WaitableEvent should automatically reset the event |
| 47 // state after a single waiting thread has been released or remain signaled |
| 48 // until Reset() is manually invoked. |
| 49 enum class ResetPolicy { MANUAL, AUTOMATIC }; |
| 50 |
| 51 // Indicates whether a new WaitableEvent should start in a signaled state or |
| 52 // not. |
| 53 enum class InitialState { SIGNALED, NOT_SIGNALED }; |
| 54 |
| 55 // Constructs a WaitableEvent with policy and initial state as detailed in |
| 56 // the above enums. |
| 57 WaitableEvent(ResetPolicy reset_policy, InitialState initial_state); |
| 58 |
46 // If manual_reset is true, then to set the event state to non-signaled, a | 59 // If manual_reset is true, then to set the event state to non-signaled, a |
47 // consumer must call the Reset method. If this parameter is false, then the | 60 // consumer must call the Reset method. If this parameter is false, then the |
48 // system automatically resets the event state to non-signaled after a single | 61 // system automatically resets the event state to non-signaled after a single |
49 // waiting thread has been released. | 62 // waiting thread has been released. |
| 63 // DEPRECATED: Use the enum-based constructor instead (full removal tracked in |
| 64 // http://crbug.com/612843). |
50 WaitableEvent(bool manual_reset, bool initially_signaled); | 65 WaitableEvent(bool manual_reset, bool initially_signaled); |
51 | 66 |
52 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
53 // Create a WaitableEvent from an Event HANDLE which has already been | 68 // Create a WaitableEvent from an Event HANDLE which has already been |
54 // created. This objects takes ownership of the HANDLE and will close it when | 69 // created. This objects takes ownership of the HANDLE and will close it when |
55 // deleted. | 70 // deleted. |
56 explicit WaitableEvent(win::ScopedHandle event_handle); | 71 explicit WaitableEvent(win::ScopedHandle event_handle); |
57 #endif | 72 #endif |
58 | 73 |
59 ~WaitableEvent(); | 74 ~WaitableEvent(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 195 |
181 scoped_refptr<WaitableEventKernel> kernel_; | 196 scoped_refptr<WaitableEventKernel> kernel_; |
182 #endif | 197 #endif |
183 | 198 |
184 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); | 199 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); |
185 }; | 200 }; |
186 | 201 |
187 } // namespace base | 202 } // namespace base |
188 | 203 |
189 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 204 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
OLD | NEW |