OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_SYSTEM_WAIT_FLAGS_STATE_H_ |
| 6 #define MOJO_SYSTEM_WAIT_FLAGS_STATE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "mojo/public/c/system/types.h" |
| 10 #include "mojo/system/system_impl_export.h" |
| 11 |
| 12 namespace mojo { |
| 13 namespace system { |
| 14 |
| 15 // Just "add" some constructors and methods to the C struct |MojoWaitFlagsState| |
| 16 // (for convenience). This should add no overhead. |
| 17 struct MOJO_SYSTEM_IMPL_EXPORT WaitFlagsState : public MojoWaitFlagsState { |
| 18 WaitFlagsState() { |
| 19 satisfied_flags = MOJO_WAIT_FLAG_NONE; |
| 20 satisfiable_flags = MOJO_WAIT_FLAG_NONE; |
| 21 } |
| 22 WaitFlagsState(MojoWaitFlags satisfied, MojoWaitFlags satisfiable) { |
| 23 satisfied_flags = satisfied; |
| 24 satisfiable_flags = satisfiable; |
| 25 } |
| 26 |
| 27 bool equals(const WaitFlagsState& other) const { |
| 28 return satisfied_flags == other.satisfied_flags && |
| 29 satisfiable_flags == other.satisfiable_flags; |
| 30 } |
| 31 |
| 32 bool satisfies(MojoWaitFlags flags) const { |
| 33 return !!(satisfied_flags & flags); |
| 34 } |
| 35 |
| 36 bool can_satisfy(MojoWaitFlags flags) const { |
| 37 return !!(satisfiable_flags & flags); |
| 38 } |
| 39 |
| 40 // (Copy and assignment allowed.) |
| 41 }; |
| 42 COMPILE_ASSERT(sizeof(WaitFlagsState) == sizeof(MojoWaitFlagsState), |
| 43 WaitFlagsState_should_add_no_overhead); |
| 44 |
| 45 } // namespace system |
| 46 } // namespace mojo |
| 47 |
| 48 #endif // MOJO_SYSTEM_WAIT_FLAGS_STATE_H_ |
OLD | NEW |