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

Unified Diff: mojo/system/waiter_list.h

Issue 23621056: Initial in-process implementation of some Mojo primitives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: C++ wrappers Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: mojo/system/waiter_list.h
diff --git a/mojo/system/waiter_list.h b/mojo/system/waiter_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..23933e3f07bb6119d1b3693a29526009be87ee50
--- /dev/null
+++ b/mojo/system/waiter_list.h
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SYSTEM_WAITER_LIST_H_
+#define MOJO_SYSTEM_WAITER_LIST_H_
+
+#include <list>
+
+#include "base/basictypes.h"
+#include "mojo/public/system/core.h"
+
+namespace mojo {
+namespace system {
+
+class Waiter;
+
+// |WaiterList| tracks all the |Waiter|s that are waiting on a given
+// handle/|Dispatcher|. There should be a |WaiterList| for each handle that can
+// be waited on (in any way). In the simple case, the |WaiterList| is owned by
+// the |Dispatcher|, whereas in more complex cases it is owned by the secondary
+// object (see simple_dispatcher.* and the explanatory comment in core_impl.cc).
+// This class is thread-unsafe (all concurrent access must be protected by some
+// lock).
+class WaiterList {
+ public:
+ WaiterList();
+ ~WaiterList();
+
+ void AwakeWaitersForStateChange(MojoWaitFlags satisfied_flags,
+ MojoWaitFlags satisfiable_flags);
+ void CancelAllWaiters();
+ void AddWaiter(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result);
+ void RemoveWaiter(Waiter* waiter);
+
+ private:
+ struct WaiterInfo {
+ WaiterInfo(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result)
+ : waiter(waiter), flags(flags), wake_result(wake_result) {}
+
+ Waiter* waiter;
+ MojoWaitFlags flags;
+ MojoResult wake_result;
+ };
+ typedef std::list<WaiterInfo> WaiterInfoList;
+
+ WaiterInfoList waiters_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaiterList);
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_SYSTEM_WAITER_LIST_H_
« mojo/system/waiter.cc ('K') | « mojo/system/waiter.cc ('k') | mojo/system/waiter_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698