| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_ |
| 6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // returns a default-constructed |HandleSignalsState|, i.e., no signals | 186 // returns a default-constructed |HandleSignalsState|, i.e., no signals |
| 187 // satisfied or satisfiable.) Note: The state is subject to change from other | 187 // satisfied or satisfiable.) Note: The state is subject to change from other |
| 188 // threads. | 188 // threads. |
| 189 HandleSignalsState GetHandleSignalsState() const; | 189 HandleSignalsState GetHandleSignalsState() const; |
| 190 | 190 |
| 191 // Adds an awakable to this dispatcher, which will be woken up when this | 191 // Adds an awakable to this dispatcher, which will be woken up when this |
| 192 // object changes state to satisfy |signals| with context |context|. It will | 192 // object changes state to satisfy |signals| with context |context|. It will |
| 193 // also be woken up when it becomes impossible for the object to ever satisfy | 193 // also be woken up when it becomes impossible for the object to ever satisfy |
| 194 // |signals| with a suitable error status. | 194 // |signals| with a suitable error status. |
| 195 // | 195 // |
| 196 // If |signals_state| is non-null, on *failure* |*signals_state| will be set | 196 // If |signals_state| is non-null, |*signals_state| will be set to the current |
| 197 // to the current handle signals state (on success, it is left untouched). | 197 // handle signals state. |
| 198 // | 198 // |
| 199 // Any awakable that's added must either eventually be removed (using | 199 // Any awakable that's added must either eventually be removed (using |
| 200 // |RemoveAwakable()| or |RemoveAwakableWithContext()|, below). If an | 200 // |RemoveAwakable()| or |RemoveAwakableWithContext()|, below). If an |
| 201 // awakable's |Awake()| is called (by this dispatcher) and it returns false, | 201 // awakable's |Awake()| is called (by this dispatcher) and it returns false, |
| 202 // that is equivalent to |RemoveAwakableWithContext()| being called for that | 202 // that is equivalent to |RemoveAwakableWithContext()| being called for that |
| 203 // awakable and the context passed to |Awake()|. | 203 // awakable and the context passed to |Awake()|. |
| 204 // | 204 // |
| 205 // Returns: | 205 // Returns: |
| 206 // - |MOJO_RESULT_OK| if the awakable was added; | 206 // - |MOJO_RESULT_OK| if the awakable was added; |
| 207 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied (if | 207 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied (if |
| 208 // |force| is true, the awakable will still be added); | 208 // |force| is true, the awakable will still be added); |
| 209 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and | 209 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and |
| 210 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible | 210 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible |
| 211 // that |signals| will ever be satisfied. | 211 // that |signals| will ever be satisfied. |
| 212 MojoResult AddAwakable(Awakable* awakable, | 212 MojoResult AddAwakable(Awakable* awakable, |
| 213 MojoHandleSignals signals, | 213 MojoHandleSignals signals, |
| 214 uint64_t context, | 214 uint64_t context, |
| 215 HandleSignalsState* signals_state); | 215 HandleSignalsState* signals_state); |
| 216 // Like |AddAwakable()|, but in the |MOJO_RESULT_ALREADY_EXISTS| case still | 216 // Like |AddAwakable()|, but in the |MOJO_RESULT_ALREADY_EXISTS| case still |
| 217 // adds the awakable (|MOJO_RESULT_ALREADY_EXISTS| will still be returned and | 217 // adds the awakable (|MOJO_RESULT_ALREADY_EXISTS| will still be returned). |
| 218 // |*signals_state| will still be set if |signals_state| is non-null). | |
| 219 MojoResult AddAwakableUnconditional(Awakable* awakable, | 218 MojoResult AddAwakableUnconditional(Awakable* awakable, |
| 220 MojoHandleSignals signals, | 219 MojoHandleSignals signals, |
| 221 uint64_t context, | 220 uint64_t context, |
| 222 HandleSignalsState* signals_state); | 221 HandleSignalsState* signals_state); |
| 223 // Removes an awakable from this dispatcher. This will remove all instances of | 222 // Removes an awakable from this dispatcher. This will remove all instances of |
| 224 // |awakable|, regardless of context. (It is valid to call this multiple times | 223 // |awakable|, regardless of context. (It is valid to call this multiple times |
| 225 // for the same |awakable| on the same object.) If |signals_state| is | 224 // for the same |awakable| on the same object.) If |signals_state| is |
| 226 // non-null, |*signals_state| will be set to the current handle signals state. | 225 // non-null, |*signals_state| will be set to the current handle signals state. |
| 227 void RemoveAwakable(Awakable* awakable, HandleSignalsState* signals_state); | 226 void RemoveAwakable(Awakable* awakable, HandleSignalsState* signals_state); |
| 228 // Like |RemoveAwakable()|, but only removes "instances" with the given | 227 // Like |RemoveAwakable()|, but only removes "instances" with the given |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 517 |
| 519 // So logging macros and |DCHECK_EQ()|, etc. work. | 518 // So logging macros and |DCHECK_EQ()|, etc. work. |
| 520 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { | 519 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { |
| 521 return out << static_cast<int>(type); | 520 return out << static_cast<int>(type); |
| 522 } | 521 } |
| 523 | 522 |
| 524 } // namespace system | 523 } // namespace system |
| 525 } // namespace mojo | 524 } // namespace mojo |
| 526 | 525 |
| 527 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ | 526 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |