OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_api.h" | 9 #include "base/base_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include <windows.h> | 13 #include <windows.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #if defined(OS_POSIX) | 16 #if defined(OS_POSIX) |
17 #include <list> | 17 #include <list> |
18 #include <utility> | 18 #include <utility> |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
(...skipping 15 matching lines...) Expand all Loading... |
35 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to | 35 // Use a WaitableEvent when you would otherwise use a Lock+ConditionVariable to |
36 // protect a simple boolean value. However, if you find yourself using a | 36 // protect a simple boolean value. However, if you find yourself using a |
37 // WaitableEvent in conjunction with a Lock to wait for a more complex state | 37 // WaitableEvent in conjunction with a Lock to wait for a more complex state |
38 // change (e.g., for an item to be added to a queue), then you should probably | 38 // change (e.g., for an item to be added to a queue), then you should probably |
39 // be using a ConditionVariable instead of a WaitableEvent. | 39 // be using a ConditionVariable instead of a WaitableEvent. |
40 // | 40 // |
41 // NOTE: On Windows, this class provides a subset of the functionality afforded | 41 // NOTE: On Windows, this class provides a subset of the functionality afforded |
42 // by a Windows event object. This is intentional. If you are writing Windows | 42 // by a Windows event object. This is intentional. If you are writing Windows |
43 // specific code and you need other features of a Windows event, then you might | 43 // specific code and you need other features of a Windows event, then you might |
44 // be better off just using an Windows event directly. | 44 // be better off just using an Windows event directly. |
45 class BASE_API WaitableEvent { | 45 class BASE_EXPORT WaitableEvent { |
46 public: | 46 public: |
47 // If manual_reset is true, then to set the event state to non-signaled, a | 47 // If manual_reset is true, then to set the event state to non-signaled, a |
48 // consumer must call the Reset method. If this parameter is false, then the | 48 // consumer must call the Reset method. If this parameter is false, then the |
49 // system automatically resets the event state to non-signaled after a single | 49 // system automatically resets the event state to non-signaled after a single |
50 // waiting thread has been released. | 50 // waiting thread has been released. |
51 WaitableEvent(bool manual_reset, bool initially_signaled); | 51 WaitableEvent(bool manual_reset, bool initially_signaled); |
52 | 52 |
53 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
54 // Create a WaitableEvent from an Event HANDLE which has already been | 54 // Create a WaitableEvent from an Event HANDLE which has already been |
55 // created. This objects takes ownership of the HANDLE and will close it when | 55 // created. This objects takes ownership of the HANDLE and will close it when |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 scoped_refptr<WaitableEventKernel> kernel_; | 173 scoped_refptr<WaitableEventKernel> kernel_; |
174 #endif | 174 #endif |
175 | 175 |
176 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); | 176 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); |
177 }; | 177 }; |
178 | 178 |
179 } // namespace base | 179 } // namespace base |
180 | 180 |
181 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 181 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
OLD | NEW |