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

Unified Diff: mojo/edk/system/awakable_list.h

Issue 779503003: Extract Awakable from Waiter (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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/edk/system/awakable_list.h
diff --git a/mojo/edk/system/awakable_list.h b/mojo/edk/system/awakable_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc42c564fb10b7974a224388ddfb97a024a741df
--- /dev/null
+++ b/mojo/edk/system/awakable_list.h
@@ -0,0 +1,66 @@
+// 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_EDK_SYSTEM_AWAKABLE_LIST_H_
+#define MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_
+
+#include <stdint.h>
+
+#include <list>
+
+#include "base/macros.h"
+#include "mojo/edk/system/system_impl_export.h"
+#include "mojo/public/c/system/types.h"
+
+namespace mojo {
+namespace system {
+
+class Awakable;
+struct HandleSignalsState;
+
+// |AwakableList| tracks all the |Waiter|s that are waiting on a given
+// handle/|Dispatcher|. There should be a |AwakableList| for each handle that
+// can
viettrungluu 2014/12/03 21:18:13 Please rewrap to 80 columns correctly.
Hajime Morrita 2014/12/03 21:44:09 Done.
+// be waited on (in any way). In the simple case, the |AwakableList| 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.cc). This
+// class is thread-unsafe (all concurrent access must be protected by some
+// lock).
+class MOJO_SYSTEM_IMPL_EXPORT AwakableList {
+ public:
+ AwakableList();
+ ~AwakableList();
+
+ void AwakeForStateChange(const HandleSignalsState& state);
+ void CancelAll();
+ void AddWaiter(Awakable* awakable,
+ MojoHandleSignals signals,
+ uint32_t context);
+ void RemoveWaiter(Awakable* awakable);
+
+ void Add(Awakable* awakable, MojoHandleSignals signals, uint32_t context) {
viettrungluu 2014/12/03 21:18:13 Just rename AddWaiter and RemoveWaiter.
Hajime Morrita 2014/12/03 21:44:09 Oops. This should've been cleaned up :-(
+ AddWaiter(awakable, signals, context);
+ }
+ void Remove(Awakable* awakable) { RemoveWaiter(awakable); }
+
+ private:
+ struct AwakeInfo {
+ AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint32_t context)
+ : awakable(awakable), signals(signals), context(context) {}
+
+ Awakable* awakable;
+ MojoHandleSignals signals;
+ uint32_t context;
+ };
+ typedef std::list<AwakeInfo> AwakeInfoList;
+
+ AwakeInfoList awakables_;
+
+ DISALLOW_COPY_AND_ASSIGN(AwakableList);
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_

Powered by Google App Engine
This is Rietveld 408576698