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

Unified Diff: mojo/system/wait_flags_state.h

Issue 325213004: Mojo: Wrap the satisfied/unsatisfied wait flags state in a single object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/simple_dispatcher_unittest.cc ('k') | mojo/system/waiter_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/wait_flags_state.h
diff --git a/mojo/system/wait_flags_state.h b/mojo/system/wait_flags_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..aaddd0c279d83304cc63a635ccd22cc933a2ecec
--- /dev/null
+++ b/mojo/system/wait_flags_state.h
@@ -0,0 +1,48 @@
+// Copyright 2014 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_WAIT_FLAGS_STATE_H_
+#define MOJO_SYSTEM_WAIT_FLAGS_STATE_H_
+
+#include "base/macros.h"
+#include "mojo/public/c/system/types.h"
+#include "mojo/system/system_impl_export.h"
+
+namespace mojo {
+namespace system {
+
+// Just "add" some constructors and methods to the C struct |MojoWaitFlagsState|
+// (for convenience). This should add no overhead.
+struct MOJO_SYSTEM_IMPL_EXPORT WaitFlagsState : public MojoWaitFlagsState {
+ WaitFlagsState() {
+ satisfied_flags = MOJO_WAIT_FLAG_NONE;
+ satisfiable_flags = MOJO_WAIT_FLAG_NONE;
+ }
+ WaitFlagsState(MojoWaitFlags satisfied, MojoWaitFlags satisfiable) {
+ satisfied_flags = satisfied;
+ satisfiable_flags = satisfiable;
+ }
+
+ bool equals(const WaitFlagsState& other) const {
+ return satisfied_flags == other.satisfied_flags &&
+ satisfiable_flags == other.satisfiable_flags;
+ }
+
+ bool satisfies(MojoWaitFlags flags) const {
+ return !!(satisfied_flags & flags);
+ }
+
+ bool can_satisfy(MojoWaitFlags flags) const {
+ return !!(satisfiable_flags & flags);
+ }
+
+ // (Copy and assignment allowed.)
+};
+COMPILE_ASSERT(sizeof(WaitFlagsState) == sizeof(MojoWaitFlagsState),
+ WaitFlagsState_should_add_no_overhead);
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_SYSTEM_WAIT_FLAGS_STATE_H_
« no previous file with comments | « mojo/system/simple_dispatcher_unittest.cc ('k') | mojo/system/waiter_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698