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.
5 #ifndef MOJO_SYSTEM_HANDLE_SIGNALS_STATE_H_
6 #define MOJO_SYSTEM_HANDLE_SIGNALS_STATE_H_
8 #include "base/macros.h"
9 #include "mojo/public/c/system/types.h"
10 #include "mojo/system/system_impl_export.h"
15 // Just "add" some constructors and methods to the C struct
16 // |MojoHandleSignalsState| (for convenience). This should add no overhead.
17 struct MOJO_SYSTEM_IMPL_EXPORT HandleSignalsState
18 : public MojoHandleSignalsState
{
19 HandleSignalsState() {
20 satisfied_signals
= MOJO_HANDLE_SIGNAL_NONE
;
21 satisfiable_signals
= MOJO_HANDLE_SIGNAL_NONE
;
23 HandleSignalsState(MojoHandleSignals satisfied
,
24 MojoHandleSignals satisfiable
) {
25 satisfied_signals
= satisfied
;
26 satisfiable_signals
= satisfiable
;
29 bool equals(const HandleSignalsState
& other
) const {
30 return satisfied_signals
== other
.satisfied_signals
&&
31 satisfiable_signals
== other
.satisfiable_signals
;
34 bool satisfies(MojoHandleSignals signals
) const {
35 return !!(satisfied_signals
& signals
);
38 bool can_satisfy(MojoHandleSignals signals
) const {
39 return !!(satisfiable_signals
& signals
);
42 // (Copy and assignment allowed.)
44 COMPILE_ASSERT(sizeof(HandleSignalsState
) == sizeof(MojoHandleSignalsState
),
45 HandleSignalsState_should_add_no_overhead
);
50 #endif // MOJO_SYSTEM_HANDLE_SIGNALS_STATE_H_