| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WAIT_SET_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_WAIT_SET_DISPATCHER_H_ |
| 6 #define MOJO_EDK_SYSTEM_WAIT_SET_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_WAIT_SET_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return AdoptRef(new WaitSetDispatcher()); | 55 return AdoptRef(new WaitSetDispatcher()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // |Dispatcher| public methods: | 58 // |Dispatcher| public methods: |
| 59 Type GetType() const override; | 59 Type GetType() const override; |
| 60 bool SupportsEntrypointClass(EntrypointClass entrypoint_class) const override; | 60 bool SupportsEntrypointClass(EntrypointClass entrypoint_class) const override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Represents an entry in the wait set. | 63 // Represents an entry in the wait set. |
| 64 struct Entry { | 64 struct Entry { |
| 65 enum class TriggerState { | 65 enum class TriggerState { NOT_TRIGGERED, SATISFIED, UNSATISFIABLE, CLOSED }; |
| 66 NOT_TRIGGERED, | |
| 67 POSSIBLY_SATISFIED, | |
| 68 NEVER_SATISFIABLE, | |
| 69 CLOSED | |
| 70 }; | |
| 71 | 66 |
| 72 Entry(MojoHandleSignals signals, uint64_t cookie); | 67 Entry(MojoHandleSignals signals, uint64_t cookie); |
| 73 ~Entry(); | 68 ~Entry(); |
| 74 | 69 |
| 75 const MojoHandleSignals signals; | 70 const MojoHandleSignals signals; |
| 76 const uint64_t cookie; | 71 const uint64_t cookie; |
| 77 // There are two cases when |dispatcher| is null for an |Entry| in | 72 // There are two cases when |dispatcher| is null for an |Entry| in |
| 78 // |WaitSetDispatcher::entries_|: | 73 // |WaitSetDispatcher::entries_|: |
| 79 // - The wait set was closed in the middle of |WaitSetAddImpl()|; | 74 // - The wait set was closed in the middle of |WaitSetAddImpl()|; |
| 80 // |entries_| will be cleared out on closing, but |WaitSetAddImpl()| | 75 // |entries_| will be cleared out on closing, but |WaitSetAddImpl()| |
| (...skipping 25 matching lines...) Expand all Loading... |
| 106 util::RefPtr<Dispatcher>&& dispatcher, | 101 util::RefPtr<Dispatcher>&& dispatcher, |
| 107 MojoHandleSignals signals, | 102 MojoHandleSignals signals, |
| 108 uint64_t cookie) override; | 103 uint64_t cookie) override; |
| 109 MojoResult WaitSetRemoveImpl(uint64_t cookie) override; | 104 MojoResult WaitSetRemoveImpl(uint64_t cookie) override; |
| 110 MojoResult WaitSetWaitImpl(MojoDeadline deadline, | 105 MojoResult WaitSetWaitImpl(MojoDeadline deadline, |
| 111 UserPointer<uint32_t> num_results, | 106 UserPointer<uint32_t> num_results, |
| 112 UserPointer<MojoWaitSetResult> results, | 107 UserPointer<MojoWaitSetResult> results, |
| 113 UserPointer<uint32_t> max_results) override; | 108 UserPointer<uint32_t> max_results) override; |
| 114 | 109 |
| 115 // |Awakable| implementation: | 110 // |Awakable| implementation: |
| 116 bool Awake(uint64_t context, | 111 void Awake(uint64_t context, |
| 117 AwakeReason reason, | 112 AwakeReason reason, |
| 118 const HandleSignalsState& signals_state) override; | 113 const HandleSignalsState& signals_state) override; |
| 119 | 114 |
| 120 void AddPossiblyTriggeredNoLock(Entry* entry, | 115 void AddPossiblyTriggeredNoLock(Entry* entry, |
| 121 Entry::TriggerState new_trigger_state) | 116 Entry::TriggerState new_trigger_state) |
| 122 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex()); | 117 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex()); |
| 123 void RemovePossiblyTriggeredNoLock(Entry* entry) | 118 void RemovePossiblyTriggeredNoLock(Entry* entry) |
| 124 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex()); | 119 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex()); |
| 125 | 120 |
| 126 // Set when in the middle of a wait set operation (i.e., |WaitSet...Impl()|) | 121 // Set when in the middle of a wait set operation (i.e., |WaitSet...Impl()|) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 140 // Size of the above list. | 135 // Size of the above list. |
| 141 size_t possibly_triggered_count_ MOJO_GUARDED_BY(mutex()) = 0u; | 136 size_t possibly_triggered_count_ MOJO_GUARDED_BY(mutex()) = 0u; |
| 142 | 137 |
| 143 MOJO_DISALLOW_COPY_AND_ASSIGN(WaitSetDispatcher); | 138 MOJO_DISALLOW_COPY_AND_ASSIGN(WaitSetDispatcher); |
| 144 }; | 139 }; |
| 145 | 140 |
| 146 } // namespace system | 141 } // namespace system |
| 147 } // namespace mojo | 142 } // namespace mojo |
| 148 | 143 |
| 149 #endif // MOJO_EDK_SYSTEM_WAIT_SET_DISPATCHER_H_ | 144 #endif // MOJO_EDK_SYSTEM_WAIT_SET_DISPATCHER_H_ |
| OLD | NEW |