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

Side by Side Diff: mojo/edk/util/waitable_event.h

Issue 1408003013: Reland "EDK: Move //mojo/edk/system/waitable_event* to edk/util." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « mojo/edk/util/ref_counted_perftest.cc ('k') | mojo/edk/util/waitable_event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // Provides classes with functionality analogous to (but much more limited than) 5 // Provides classes with functionality analogous to (but much more limited than)
6 // Chromium's |base::WaitableEvent|, which in turn provides functionality 6 // Chromium's |base::WaitableEvent|, which in turn provides functionality
7 // analogous to Windows's Event. (Unlike these two, we have separate types for 7 // analogous to Windows's Event. (Unlike these two, we have separate types for
8 // the manual- and auto-reset versions.) 8 // the manual- and auto-reset versions.)
9 9
10 #ifndef MOJO_EDK_SYSTEM_WAITABLE_EVENT_H_ 10 #ifndef MOJO_EDK_UTIL_WAITABLE_EVENT_H_
11 #define MOJO_EDK_SYSTEM_WAITABLE_EVENT_H_ 11 #define MOJO_EDK_UTIL_WAITABLE_EVENT_H_
12 12
13 #include "mojo/edk/util/cond_var.h" 13 #include "mojo/edk/util/cond_var.h"
14 #include "mojo/edk/util/mutex.h" 14 #include "mojo/edk/util/mutex.h"
15 #include "mojo/edk/util/thread_annotations.h" 15 #include "mojo/edk/util/thread_annotations.h"
16 #include "mojo/public/cpp/system/macros.h" 16 #include "mojo/public/cpp/system/macros.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace system { 19 namespace util {
20 20
21 // AutoResetWaitableEvent ------------------------------------------------------ 21 // AutoResetWaitableEvent ------------------------------------------------------
22 22
23 // An event that can be signaled and waited on. This version automatically 23 // An event that can be signaled and waited on. This version automatically
24 // returns to the unsignaled state after unblocking one waiter. (This is similar 24 // returns to the unsignaled state after unblocking one waiter. (This is similar
25 // to Windows's auto-reset Event, which is also imitated by Chromium's 25 // to Windows's auto-reset Event, which is also imitated by Chromium's
26 // auto-reset |base::WaitableEvent|. However, there are some limitations -- see 26 // auto-reset |base::WaitableEvent|. However, there are some limitations -- see
27 // |Signal()|.) This class is thread-safe. 27 // |Signal()|.) This class is thread-safe.
28 class AutoResetWaitableEvent { 28 class AutoResetWaitableEvent {
29 public: 29 public:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // waiting threads, one has to deal with spurious wake-ups. Checking 114 // waiting threads, one has to deal with spurious wake-ups. Checking
115 // |signaled_| isn't sufficient, since another thread may have been awoken and 115 // |signaled_| isn't sufficient, since another thread may have been awoken and
116 // (manually) reset |signaled_|. This is a counter that is incremented in 116 // (manually) reset |signaled_|. This is a counter that is incremented in
117 // |Signal()| before calling |CondVar::SignalAll()|. A waiting thread knows it 117 // |Signal()| before calling |CondVar::SignalAll()|. A waiting thread knows it
118 // was awoken if |signal_id_| is different from when it started waiting. 118 // was awoken if |signal_id_| is different from when it started waiting.
119 unsigned signal_id_ MOJO_GUARDED_BY(mutex_) = 0u; 119 unsigned signal_id_ MOJO_GUARDED_BY(mutex_) = 0u;
120 120
121 MOJO_DISALLOW_COPY_AND_ASSIGN(ManualResetWaitableEvent); 121 MOJO_DISALLOW_COPY_AND_ASSIGN(ManualResetWaitableEvent);
122 }; 122 };
123 123
124 } // namespace system 124 } // namespace util
125 } // namespace mojo 125 } // namespace mojo
126 126
127 #endif // MOJO_EDK_SYSTEM_WAITABLE_EVENT_H_ 127 #endif // MOJO_EDK_UTIL_WAITABLE_EVENT_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/ref_counted_perftest.cc ('k') | mojo/edk/util/waitable_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698