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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 protected: | 148 protected: |
149 virtual ~Waiter() {} | 149 virtual ~Waiter() {} |
150 }; | 150 }; |
151 | 151 |
152 private: | 152 private: |
153 friend class WaitableEventWatcher; | 153 friend class WaitableEventWatcher; |
154 | 154 |
155 #if defined(OS_WIN) | 155 #if defined(OS_WIN) |
156 win::ScopedHandle handle_; | 156 win::ScopedHandle handle_; |
157 #else | 157 #else |
158 // On Windows, one can close a HANDLE which is currently being waited on. The | 158 // On Windows, you must not close a HANDLE which is currently being waited on. |
159 // MSDN documentation says that the resulting behaviour is 'undefined', but | 159 // The MSDN documentation says that the resulting behaviour is 'undefined'. |
160 // it doesn't crash. However, if we were to include the following members | 160 // To solve that issue each WaitableEventWatcher duplicates the given event |
| 161 // handle. |
| 162 |
| 163 // However, if we were to include the following members |
161 // directly then, on POSIX, one couldn't use WaitableEventWatcher to watch an | 164 // directly then, on POSIX, one couldn't use WaitableEventWatcher to watch an |
162 // event which gets deleted. This mismatch has bitten us several times now, | 165 // event which gets deleted. This mismatch has bitten us several times now, |
163 // so we have a kernel of the WaitableEvent, which is reference counted. | 166 // so we have a kernel of the WaitableEvent, which is reference counted. |
164 // WaitableEventWatchers may then take a reference and thus match the Windows | 167 // WaitableEventWatchers may then take a reference and thus match the Windows |
165 // behaviour. | 168 // behaviour. |
166 struct WaitableEventKernel : | 169 struct WaitableEventKernel : |
167 public RefCountedThreadSafe<WaitableEventKernel> { | 170 public RefCountedThreadSafe<WaitableEventKernel> { |
168 public: | 171 public: |
169 WaitableEventKernel(ResetPolicy reset_policy, InitialState initial_state); | 172 WaitableEventKernel(ResetPolicy reset_policy, InitialState initial_state); |
170 | 173 |
(...skipping 25 matching lines...) Expand all Loading... |
196 | 199 |
197 scoped_refptr<WaitableEventKernel> kernel_; | 200 scoped_refptr<WaitableEventKernel> kernel_; |
198 #endif | 201 #endif |
199 | 202 |
200 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); | 203 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); |
201 }; | 204 }; |
202 | 205 |
203 } // namespace base | 206 } // namespace base |
204 | 207 |
205 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 208 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
OLD | NEW |