| 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 "base/synchronization/condition_variable.h" | 10 #include "base/synchronization/condition_variable.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "mojo/edk/system/awakable.h" | 12 #include "mojo/edk/system/awakable.h" |
| 13 #include "mojo/edk/system/system_impl_export.h" | |
| 14 #include "mojo/public/c/system/types.h" | 13 #include "mojo/public/c/system/types.h" |
| 15 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace system { | 17 namespace system { |
| 19 | 18 |
| 20 // IMPORTANT (all-caps gets your attention, right?): |Waiter| methods are called | 19 // IMPORTANT (all-caps gets your attention, right?): |Waiter| methods are called |
| 21 // under other locks, in particular, |Dispatcher::lock_|s, so |Waiter| methods | 20 // under other locks, in particular, |Dispatcher::lock_|s, so |Waiter| methods |
| 22 // must never call out to other objects (in particular, |Dispatcher|s). This | 21 // must never call out to other objects (in particular, |Dispatcher|s). This |
| 23 // class is thread-safe. | 22 // class is thread-safe. |
| 24 class MOJO_SYSTEM_IMPL_EXPORT Waiter final : public Awakable { | 23 class Waiter final : public Awakable { |
| 25 public: | 24 public: |
| 26 Waiter(); | 25 Waiter(); |
| 27 ~Waiter(); | 26 ~Waiter() override; |
| 28 | 27 |
| 29 // A |Waiter| can be used multiple times; |Init()| should be called before | 28 // A |Waiter| can be used multiple times; |Init()| should be called before |
| 30 // each time it's used. | 29 // each time it's used. |
| 31 void Init(); | 30 void Init(); |
| 32 | 31 |
| 33 // Waits until a suitable |Awake()| is called. (|context| may be null, in | 32 // Waits until a suitable |Awake()| is called. (|context| may be null, in |
| 34 // which case, obviously no context is ever returned.) | 33 // which case, obviously no context is ever returned.) |
| 35 // Returns: | 34 // Returns: |
| 36 // - The result given to the first call to |Awake()| (possibly before this | 35 // - The result given to the first call to |Awake()| (possibly before this |
| 37 // call to |Wait()|); in this case, |*context| is set to the value passed | 36 // call to |Wait()|); in this case, |*context| is set to the value passed |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 MojoResult awake_result_; | 69 MojoResult awake_result_; |
| 71 uintptr_t awake_context_; | 70 uintptr_t awake_context_; |
| 72 | 71 |
| 73 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); | 72 MOJO_DISALLOW_COPY_AND_ASSIGN(Waiter); |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 } // namespace system | 75 } // namespace system |
| 77 } // namespace mojo | 76 } // namespace mojo |
| 78 | 77 |
| 79 #endif // MOJO_EDK_SYSTEM_WAITER_H_ | 78 #endif // MOJO_EDK_SYSTEM_WAITER_H_ |
| OLD | NEW |