| 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_LIST_H_ | 5 #ifndef MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ |
| 6 #define MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ | 6 #define MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // comment in core.cc). This class is thread-unsafe (all concurrent access must | 26 // comment in core.cc). This class is thread-unsafe (all concurrent access must |
| 27 // be protected by some lock). | 27 // be protected by some lock). |
| 28 class AwakableList { | 28 class AwakableList { |
| 29 public: | 29 public: |
| 30 AwakableList(); | 30 AwakableList(); |
| 31 ~AwakableList(); | 31 ~AwakableList(); |
| 32 | 32 |
| 33 void OnStateChange(const HandleSignalsState& old_state, | 33 void OnStateChange(const HandleSignalsState& old_state, |
| 34 const HandleSignalsState& new_state); | 34 const HandleSignalsState& new_state); |
| 35 void CancelAll(); | 35 void CancelAll(); |
| 36 void Add(Awakable* awakable, MojoHandleSignals signals, uint64_t context); | 36 |
| 37 void Remove(Awakable* awakable); | 37 // Adds an awakable, identified by its pointer and its context. |
| 38 void RemoveWithContext(Awakable* awakable, uint64_t context); | 38 void Add(Awakable* awakable, uint64_t context, MojoHandleSignals signals); |
| 39 |
| 40 // Removes all awakables matching the given pointer and, if |match_context| is |
| 41 // true, the given context. |
| 42 void Remove(bool match_context, Awakable* awakable, uint64_t context); |
| 39 | 43 |
| 40 private: | 44 private: |
| 41 struct AwakeInfo { | 45 struct AwakeInfo { |
| 42 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint64_t context) | 46 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint64_t context) |
| 43 : awakable(awakable), signals(signals), context(context) {} | 47 : awakable(awakable), signals(signals), context(context) {} |
| 44 | 48 |
| 45 Awakable* awakable; | 49 Awakable* awakable; |
| 46 MojoHandleSignals signals; | 50 MojoHandleSignals signals; |
| 47 uint64_t context; | 51 uint64_t context; |
| 48 }; | 52 }; |
| 49 using AwakeInfoList = std::vector<AwakeInfo>; | 53 using AwakeInfoList = std::vector<AwakeInfo>; |
| 50 | 54 |
| 51 AwakeInfoList awakables_; | 55 AwakeInfoList awakables_; |
| 52 | 56 |
| 53 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); | 57 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 } // namespace system | 60 } // namespace system |
| 57 } // namespace mojo | 61 } // namespace mojo |
| 58 | 62 |
| 59 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ | 63 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ |
| OLD | NEW |