| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Adds an awakable, identified by its pointer and its context. | 39 // Adds an awakable, identified by its pointer and its context. |
| 40 // | 40 // |
| 41 // An awakable may either be persistent or one-shot (non-persistent). | 41 // An awakable may either be persistent or one-shot (non-persistent). |
| 42 // - A one-shot's |Awake()| will be called at most once per |Add()|, and | 42 // - A one-shot's |Awake()| will be called at most once per |Add()|, and |
| 43 // will only be called if a watched signal goes from unsatisfied to | 43 // will only be called if a watched signal goes from unsatisfied to |
| 44 // satisfied (|Awake()| will be called with reason | 44 // satisfied (|Awake()| will be called with reason |
| 45 // |Awakable::AwakeReason::SATISFIED|), all watched signals become | 45 // |Awakable::AwakeReason::SATISFIED|), all watched signals become |
| 46 // never-satisfiable (|Awakable::AwakeReason::UNSATISFIABLE|), or | 46 // never-satisfiable (|Awakable::AwakeReason::UNSATISFIABLE|), or |
| 47 // |CancelAndRemoveAll()| is called (|Awakable::AwakeReason::CANCELLED|). | 47 // |CancelAndRemoveAll()| is called (|Awakable::AwakeReason::CANCELLED|). |
| 48 // - A persistent awakable's |Awake()| will be called for all state changes | 48 // - A persistent awakable's |Awake()| will be called inside |Add()| (under |
| 49 // on watched signals (with reason |Awakable::AwakeReason::CHANGED|) until | 49 // any mutex protecting the |AwakableList()| -- this is similar to |
| 50 // |CancelAndRemoveAll()| is called (at which point its |Awake()| will be | 50 // |OnStateChange()|) (with reason |Awakable::AwakeReason::INITIALIZE|), |
| 51 // called a final time with reason |Awakable::AwakeReason::CANCELLED|). | 51 // and then subsequently for all state changes on watched signals |
| 52 // (|Awakable::AwakeReason::CHANGED|) until |CancelAndRemoveAll()| is |
| 53 // called (at which point its |Awake()| will be called a final time with |
| 54 // reason |Awakable::AwakeReason::CANCELLED|). |
| 52 void Add(Awakable* awakable, | 55 void Add(Awakable* awakable, |
| 53 uint64_t context, | 56 uint64_t context, |
| 54 bool persistent, | 57 bool persistent, |
| 55 MojoHandleSignals signals); | 58 MojoHandleSignals signals, |
| 59 const HandleSignalsState& current_state); |
| 56 | 60 |
| 57 // Removes all awakables matching the given pointer and, if |match_context| is | 61 // Removes all awakables matching the given pointer and, if |match_context| is |
| 58 // true, the given context. | 62 // true, the given context. |
| 59 void Remove(bool match_context, Awakable* awakable, uint64_t context); | 63 void Remove(bool match_context, Awakable* awakable, uint64_t context); |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 struct AwakeInfo { | 66 struct AwakeInfo { |
| 63 AwakeInfo(Awakable* awakable, | 67 AwakeInfo(Awakable* awakable, |
| 64 uint64_t context, | 68 uint64_t context, |
| 65 bool persistent, | 69 bool persistent, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 | 82 |
| 79 AwakeInfoList awakables_; | 83 AwakeInfoList awakables_; |
| 80 | 84 |
| 81 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); | 85 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); |
| 82 }; | 86 }; |
| 83 | 87 |
| 84 } // namespace system | 88 } // namespace system |
| 85 } // namespace mojo | 89 } // namespace mojo |
| 86 | 90 |
| 87 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ | 91 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ |
| OLD | NEW |