OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ |
6 #define MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ | 6 #define MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ |
7 | 7 |
8 #include "mojo/edk/system/system_impl_export.h" | 8 #include "mojo/public/cpp/system/handle_signals_state.h" |
9 #include "mojo/public/c/system/types.h" | |
10 | 9 |
11 namespace mojo { | 10 // TODO(rockot): Remove this header and use the C++ system library type |
12 namespace edk { | 11 // directly inside the EDK. |
13 | |
14 // Just "add" some constructors and methods to the C struct | |
15 // |MojoHandleSignalsState| (for convenience). This should add no overhead. | |
16 struct MOJO_SYSTEM_IMPL_EXPORT HandleSignalsState final | |
17 : public MojoHandleSignalsState { | |
18 HandleSignalsState() { | |
19 satisfied_signals = MOJO_HANDLE_SIGNAL_NONE; | |
20 satisfiable_signals = MOJO_HANDLE_SIGNAL_NONE; | |
21 } | |
22 HandleSignalsState(MojoHandleSignals satisfied, | |
23 MojoHandleSignals satisfiable) { | |
24 satisfied_signals = satisfied; | |
25 satisfiable_signals = satisfiable; | |
26 } | |
27 | |
28 bool equals(const HandleSignalsState& other) const { | |
29 return satisfied_signals == other.satisfied_signals && | |
30 satisfiable_signals == other.satisfiable_signals; | |
31 } | |
32 | |
33 bool satisfies(MojoHandleSignals signals) const { | |
34 return !!(satisfied_signals & signals); | |
35 } | |
36 | |
37 bool can_satisfy(MojoHandleSignals signals) const { | |
38 return !!(satisfiable_signals & signals); | |
39 } | |
40 | |
41 // (Copy and assignment allowed.) | |
42 }; | |
43 static_assert(sizeof(HandleSignalsState) == sizeof(MojoHandleSignalsState), | |
44 "HandleSignalsState should add no overhead"); | |
45 | |
46 } // namespace edk | |
47 } // namespace mojo | |
48 | 12 |
49 #endif // MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ | 13 #endif // MOJO_EDK_SYSTEM_HANDLE_SIGNALS_STATE_H_ |
OLD | NEW |