| 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" |
| 11 #include "mojo/edk/system/cond_var.h" | 11 #include "mojo/edk/util/cond_var.h" |
| 12 #include "mojo/edk/system/mutex.h" | 12 #include "mojo/edk/util/mutex.h" |
| 13 #include "mojo/edk/system/thread_annotations.h" | 13 #include "mojo/edk/util/thread_annotations.h" |
| 14 #include "mojo/public/c/system/types.h" | 14 #include "mojo/public/c/system/types.h" |
| 15 #include "mojo/public/cpp/system/macros.h" | 15 #include "mojo/public/cpp/system/macros.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 namespace system { | 18 namespace system { |
| 19 | 19 |
| 20 // IMPORTANT (all-caps gets your attention, right?): |Waiter| methods are called | 20 // IMPORTANT (all-caps gets your attention, right?): |Waiter| methods are called |
| 21 // under other locks, in particular, |Dispatcher::lock_|s, so |Waiter| methods | 21 // under other locks, in particular, |Dispatcher::lock_|s, so |Waiter| methods |
| 22 // must never call out to other objects (in particular, |Dispatcher|s). This | 22 // must never call out to other objects (in particular, |Dispatcher|s). This |
| 23 // class is thread-safe. | 23 // class is thread-safe. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 54 // |MojoWait()|/|MojoWaitMany()| cannot or can no longer be satisfied by | 54 // |MojoWait()|/|MojoWaitMany()| cannot or can no longer be satisfied by |
| 55 // the corresponding handle (e.g., if the other end of a message or data | 55 // the corresponding handle (e.g., if the other end of a message or data |
| 56 // pipe is closed). | 56 // pipe is closed). |
| 57 MojoResult Wait(MojoDeadline deadline, uint32_t* context); | 57 MojoResult Wait(MojoDeadline deadline, uint32_t* context); |
| 58 | 58 |
| 59 // Wake the waiter up with the given result and context (or no-op if it's been | 59 // Wake the waiter up with the given result and context (or no-op if it's been |
| 60 // woken up already). | 60 // woken up already). |
| 61 bool Awake(MojoResult result, uintptr_t context) override; | 61 bool Awake(MojoResult result, uintptr_t context) override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 CondVar cv_; // Associated to |mutex_|. | 64 util::CondVar cv_; // Associated to |mutex_|. |
| 65 Mutex mutex_; | 65 util::Mutex mutex_; |
| 66 #ifndef NDEBUG | 66 #ifndef NDEBUG |
| 67 bool initialized_ MOJO_GUARDED_BY(mutex_); | 67 bool initialized_ MOJO_GUARDED_BY(mutex_); |
| 68 #endif | 68 #endif |
| 69 bool awoken_ MOJO_GUARDED_BY(mutex_); | 69 bool awoken_ MOJO_GUARDED_BY(mutex_); |
| 70 MojoResult awake_result_ MOJO_GUARDED_BY(mutex_); | 70 MojoResult awake_result_ MOJO_GUARDED_BY(mutex_); |
| 71 uintptr_t awake_context_ MOJO_GUARDED_BY(mutex_); | 71 uintptr_t awake_context_ MOJO_GUARDED_BY(mutex_); |
| 72 | 72 |
| 73 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); | 73 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace system | 76 } // namespace system |
| 77 } // namespace mojo | 77 } // namespace mojo |
| 78 | 78 |
| 79 #endif // MOJO_EDK_SYSTEM_WAITER_H_ | 79 #endif // MOJO_EDK_SYSTEM_WAITER_H_ |
| OLD | NEW |