| 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_WAITER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_WAITER_H_ |
| 6 #define MOJO_EDK_SYSTEM_WAITER_H_ | 6 #define MOJO_EDK_SYSTEM_WAITER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/edk/system/awakable.h" | 10 #include "mojo/edk/system/awakable.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // satisfied; | 50 // satisfied; |
| 51 // - |MOJO_RESULT_CANCELLED| if a handle (on which | 51 // - |MOJO_RESULT_CANCELLED| if a handle (on which |
| 52 // |MojoWait()|/|MojoWaitMany()| was called) was closed (hence the | 52 // |MojoWait()|/|MojoWaitMany()| was called) was closed (hence the |
| 53 // dispatcher closed); and | 53 // dispatcher closed); and |
| 54 // - |MOJO_RESULT_FAILED_PRECONDITION| if one of the set of flags passed to | 54 // - |MOJO_RESULT_FAILED_PRECONDITION| if one of the set of flags passed to |
| 55 // |MojoWait()|/|MojoWaitMany()| cannot or can no longer be satisfied by | 55 // |MojoWait()|/|MojoWaitMany()| cannot or can no longer be satisfied by |
| 56 // the corresponding handle (e.g., if the other end of a message or data | 56 // the corresponding handle (e.g., if the other end of a message or data |
| 57 // pipe is closed). | 57 // pipe is closed). |
| 58 MojoResult Wait(MojoDeadline deadline, uint64_t* context); | 58 MojoResult Wait(MojoDeadline deadline, uint64_t* context); |
| 59 | 59 |
| 60 // Wake the waiter up with the given result and context (or no-op if it's been | 60 // |Awakable| implementation: |
| 61 // woken up already). | 61 bool Awake(uint64_t context, |
| 62 bool Awake(MojoResult result, uint64_t context) override; | 62 AwakeReason reason, |
| 63 const HandleSignalsState& signals_state) override; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 util::CondVar cv_; // Associated to |mutex_|. | 66 util::CondVar cv_; // Associated to |mutex_|. |
| 66 util::Mutex mutex_; | 67 util::Mutex mutex_; |
| 67 #ifndef NDEBUG | 68 #ifndef NDEBUG |
| 68 bool initialized_ MOJO_GUARDED_BY(mutex_); | 69 bool initialized_ MOJO_GUARDED_BY(mutex_); |
| 69 #endif | 70 #endif |
| 70 bool awoken_ MOJO_GUARDED_BY(mutex_); | 71 bool awoken_ MOJO_GUARDED_BY(mutex_); |
| 71 MojoResult awake_result_ MOJO_GUARDED_BY(mutex_); | 72 MojoResult awake_result_ MOJO_GUARDED_BY(mutex_); |
| 72 uint64_t awake_context_ MOJO_GUARDED_BY(mutex_); | 73 uint64_t awake_context_ MOJO_GUARDED_BY(mutex_); |
| 73 | 74 |
| 74 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); | 75 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 } // namespace system | 78 } // namespace system |
| 78 } // namespace mojo | 79 } // namespace mojo |
| 79 | 80 |
| 80 #endif // MOJO_EDK_SYSTEM_WAITER_H_ | 81 #endif // MOJO_EDK_SYSTEM_WAITER_H_ |
| OLD | NEW |