| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, on *failure* |*signals_state| will be set |
| 197 // to the current handle signals state (on success, it is left untouched). | 197 // to the current handle signals state (on success, it is left untouched). |
| 198 // | 198 // |
| 199 // Returns: | 199 // Returns: |
| 200 // - |MOJO_RESULT_OK| if the awakable was added; | 200 // - |MOJO_RESULT_OK| if the awakable was added; |
| 201 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied; | 201 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied (if |
| 202 // |force| is true, the awakable will still be added); |
| 202 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and | 203 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and |
| 203 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible | 204 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible |
| 204 // that |signals| will ever be satisfied. | 205 // that |signals| will ever be satisfied. |
| 205 MojoResult AddAwakable(Awakable* awakable, | 206 MojoResult AddAwakable(Awakable* awakable, |
| 206 MojoHandleSignals signals, | 207 MojoHandleSignals signals, |
| 207 uint64_t context, | 208 uint64_t context, |
| 208 HandleSignalsState* signals_state); | 209 HandleSignalsState* signals_state); |
| 210 // Like |AddAwakable()|, but in the |MOJO_RESULT_ALREADY_EXISTS| case still |
| 211 // adds the awakable (|MOJO_RESULT_ALREADY_EXISTS| will still be returned and |
| 212 // |*signals_state| will still be set if |signals_state| is non-null). |
| 213 MojoResult AddAwakableUnconditional(Awakable* awakable, |
| 214 MojoHandleSignals signals, |
| 215 uint64_t context, |
| 216 HandleSignalsState* signals_state); |
| 209 // Removes an awakable from this dispatcher. (It is valid to call this | 217 // Removes an awakable from this dispatcher. (It is valid to call this |
| 210 // multiple times for the same |awakable| on the same object, so long as | 218 // multiple times for the same |awakable| on the same object, so long as |
| 211 // |AddAwakable()| was called at most once.) If |signals_state| is non-null, | 219 // |AddAwakable()| was called at most once.) If |signals_state| is non-null, |
| 212 // |*signals_state| will be set to the current handle signals state. | 220 // |*signals_state| will be set to the current handle signals state. |
| 213 void RemoveAwakable(Awakable* awakable, HandleSignalsState* signals_state); | 221 void RemoveAwakable(Awakable* awakable, HandleSignalsState* signals_state); |
| 214 | 222 |
| 215 // A dispatcher must be put into a special state in order to be sent across a | 223 // A dispatcher must be put into a special state in order to be sent across a |
| 216 // message pipe. Outside of tests, only |HandleTableAccess| is allowed to do | 224 // message pipe. Outside of tests, only |HandleTableAccess| is allowed to do |
| 217 // this, since there are requirements on the handle table (see below). | 225 // this, since there are requirements on the handle table (see below). |
| 218 // | 226 // |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 // check |is_closed_no_lock()| (returning |MOJO_RESULT_INVALID_ARGUMENT| if it | 384 // check |is_closed_no_lock()| (returning |MOJO_RESULT_INVALID_ARGUMENT| if it |
| 377 // is true). | 385 // is true). |
| 378 virtual MojoResult WaitSetWaitImpl(MojoDeadline deadline, | 386 virtual MojoResult WaitSetWaitImpl(MojoDeadline deadline, |
| 379 UserPointer<uint32_t> num_results, | 387 UserPointer<uint32_t> num_results, |
| 380 UserPointer<MojoWaitSetResult> results, | 388 UserPointer<MojoWaitSetResult> results, |
| 381 UserPointer<uint32_t> max_results); | 389 UserPointer<uint32_t> max_results); |
| 382 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const | 390 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const |
| 383 MOJO_SHARED_LOCKS_REQUIRED(mutex_); | 391 MOJO_SHARED_LOCKS_REQUIRED(mutex_); |
| 384 virtual MojoResult AddAwakableImplNoLock(Awakable* awakable, | 392 virtual MojoResult AddAwakableImplNoLock(Awakable* awakable, |
| 385 MojoHandleSignals signals, | 393 MojoHandleSignals signals, |
| 394 bool force, |
| 386 uint64_t context, | 395 uint64_t context, |
| 387 HandleSignalsState* signals_state) | 396 HandleSignalsState* signals_state) |
| 388 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 397 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
| 389 virtual void RemoveAwakableImplNoLock(Awakable* awakable, | 398 virtual void RemoveAwakableImplNoLock(Awakable* awakable, |
| 390 HandleSignalsState* signals_state) | 399 HandleSignalsState* signals_state) |
| 391 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 400 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
| 392 | 401 |
| 393 // These implement the API used to serialize dispatchers to a |Channel| | 402 // These implement the API used to serialize dispatchers to a |Channel| |
| 394 // (described below). They will only be called on a dispatcher that's attached | 403 // (described below). They will only be called on a dispatcher that's attached |
| 395 // to and "owned" by a |MessageInTransit|. See the non-"impl" versions for | 404 // to and "owned" by a |MessageInTransit|. See the non-"impl" versions for |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 503 |
| 495 // So logging macros and |DCHECK_EQ()|, etc. work. | 504 // So logging macros and |DCHECK_EQ()|, etc. work. |
| 496 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { | 505 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { |
| 497 return out << static_cast<int>(type); | 506 return out << static_cast<int>(type); |
| 498 } | 507 } |
| 499 | 508 |
| 500 } // namespace system | 509 } // namespace system |
| 501 } // namespace mojo | 510 } // namespace mojo |
| 502 | 511 |
| 503 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ | 512 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |