| 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_AWAKABLE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_AWAKABLE_H_ |
| 6 #define MOJO_EDK_SYSTEM_AWAKABLE_H_ | 6 #define MOJO_EDK_SYSTEM_AWAKABLE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/public/c/system/result.h" | 10 #include "mojo/public/c/system/result.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace system { | 13 namespace system { |
| 14 | 14 |
| 15 // An interface for things that may be awoken. E.g., |Waiter| is an | 15 // An interface for things that may be awoken. E.g., |Waiter| is an |
| 16 // implementation that blocks while waiting to be awoken. | 16 // implementation that blocks while waiting to be awoken. |
| 17 class Awakable { | 17 class Awakable { |
| 18 public: | 18 public: |
| 19 // |Awake()| must satisfy the following contract: | 19 // |Awake()| must satisfy the following contract: |
| 20 // - It must be thread-safe. | 20 // - It must be thread-safe. |
| 21 // - Since it is called with a mutex held, it must not call anything that | 21 // - Since it is called with a mutex held, it must not call anything that |
| 22 // takes "non-terminal" locks, i.e., those which are always safe to take. | 22 // takes "non-terminal" locks, i.e., those which are always safe to take. |
| 23 // - It should return false if it must not be called again for the same | 23 // - It should return false if it must not be called again for the same |
| 24 // reason (e.g., for the same call to |AwakableList::Add()|). | 24 // reason (e.g., for the same call to |AwakableList::Add()|). |
| 25 virtual bool Awake(MojoResult result, uintptr_t context) = 0; | 25 virtual bool Awake(MojoResult result, uint64_t context) = 0; |
| 26 | 26 |
| 27 protected: | 27 protected: |
| 28 Awakable() {} | 28 Awakable() {} |
| 29 virtual ~Awakable() {} | 29 virtual ~Awakable() {} |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 } // namespace system | 32 } // namespace system |
| 33 } // namespace mojo | 33 } // namespace mojo |
| 34 | 34 |
| 35 #endif // MOJO_EDK_SYSTEM_AWAKABLE_H_ | 35 #endif // MOJO_EDK_SYSTEM_AWAKABLE_H_ |
| OLD | NEW |