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

Side by Side Diff: base/synchronization/waitable_event.h

Issue 2030683005: Remove boolean-based WaitableEvent constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_thread_watcher
Patch Set: Created 4 years, 6 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
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 enum class ResetPolicy { MANUAL, AUTOMATIC }; 49 enum class ResetPolicy { MANUAL, AUTOMATIC };
50 50
51 // Indicates whether a new WaitableEvent should start in a signaled state or 51 // Indicates whether a new WaitableEvent should start in a signaled state or
52 // not. 52 // not.
53 enum class InitialState { SIGNALED, NOT_SIGNALED }; 53 enum class InitialState { SIGNALED, NOT_SIGNALED };
54 54
55 // Constructs a WaitableEvent with policy and initial state as detailed in 55 // Constructs a WaitableEvent with policy and initial state as detailed in
56 // the above enums. 56 // the above enums.
57 WaitableEvent(ResetPolicy reset_policy, InitialState initial_state); 57 WaitableEvent(ResetPolicy reset_policy, InitialState initial_state);
58 58
59 // If manual_reset is true, then to set the event state to non-signaled, a
60 // consumer must call the Reset method. If this parameter is false, then the
61 // system automatically resets the event state to non-signaled after a single
62 // waiting thread has been released.
63 // DEPRECATED: Use the enum-based constructor instead (full removal tracked in
64 // http://crbug.com/612843).
65 WaitableEvent(bool manual_reset, bool initially_signaled);
66
67 #if defined(OS_WIN) 59 #if defined(OS_WIN)
68 // Create a WaitableEvent from an Event HANDLE which has already been 60 // Create a WaitableEvent from an Event HANDLE which has already been
69 // created. This objects takes ownership of the HANDLE and will close it when 61 // created. This objects takes ownership of the HANDLE and will close it when
70 // deleted. 62 // deleted.
71 explicit WaitableEvent(win::ScopedHandle event_handle); 63 explicit WaitableEvent(win::ScopedHandle event_handle);
72 #endif 64 #endif
73 65
74 ~WaitableEvent(); 66 ~WaitableEvent();
75 67
76 // Put the event in the un-signaled state. 68 // Put the event in the un-signaled state.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // MSDN documentation says that the resulting behaviour is 'undefined', but 150 // MSDN documentation says that the resulting behaviour is 'undefined', but
159 // it doesn't crash. However, if we were to include the following members 151 // it doesn't crash. However, if we were to include the following members
160 // directly then, on POSIX, one couldn't use WaitableEventWatcher to watch an 152 // directly then, on POSIX, one couldn't use WaitableEventWatcher to watch an
161 // event which gets deleted. This mismatch has bitten us several times now, 153 // event which gets deleted. This mismatch has bitten us several times now,
162 // so we have a kernel of the WaitableEvent, which is reference counted. 154 // so we have a kernel of the WaitableEvent, which is reference counted.
163 // WaitableEventWatchers may then take a reference and thus match the Windows 155 // WaitableEventWatchers may then take a reference and thus match the Windows
164 // behaviour. 156 // behaviour.
165 struct WaitableEventKernel : 157 struct WaitableEventKernel :
166 public RefCountedThreadSafe<WaitableEventKernel> { 158 public RefCountedThreadSafe<WaitableEventKernel> {
167 public: 159 public:
168 WaitableEventKernel(bool manual_reset, bool initially_signaled); 160 WaitableEventKernel(ResetPolicy reset_policy, InitialState initial_state);
169 161
170 bool Dequeue(Waiter* waiter, void* tag); 162 bool Dequeue(Waiter* waiter, void* tag);
171 163
172 base::Lock lock_; 164 base::Lock lock_;
173 const bool manual_reset_; 165 const bool manual_reset_;
174 bool signaled_; 166 bool signaled_;
175 std::list<Waiter*> waiters_; 167 std::list<Waiter*> waiters_;
176 168
177 private: 169 private:
178 friend class RefCountedThreadSafe<WaitableEventKernel>; 170 friend class RefCountedThreadSafe<WaitableEventKernel>;
(...skipping 16 matching lines...) Expand all
195 187
196 scoped_refptr<WaitableEventKernel> kernel_; 188 scoped_refptr<WaitableEventKernel> kernel_;
197 #endif 189 #endif
198 190
199 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); 191 DISALLOW_COPY_AND_ASSIGN(WaitableEvent);
200 }; 192 };
201 193
202 } // namespace base 194 } // namespace base
203 195
204 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ 196 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/synchronization/waitable_event_posix.cc » ('j') | base/synchronization/waitable_event_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698