OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_SYSTEM_WAITER_LIST_H_ |
| 6 #define MOJO_SYSTEM_WAITER_LIST_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "mojo/public/system/core.h" |
| 12 |
| 13 namespace mojo { |
| 14 namespace system { |
| 15 |
| 16 class Waiter; |
| 17 |
| 18 // |WaiterList| tracks all the |Waiter|s that are waiting on a given |
| 19 // handle/|Dispatcher|. There should be a |WaiterList| for each handle that can |
| 20 // be waited on (in any way). In the simple case, the |WaiterList| is owned by |
| 21 // the |Dispatcher|, whereas in more complex cases it is owned by the secondary |
| 22 // object (see simple_dispatcher.* and the explanatory comment in core_impl.cc). |
| 23 // This class is thread-unsafe (all concurrent access must be protected by some |
| 24 // lock). |
| 25 class WaiterList { |
| 26 public: |
| 27 WaiterList(); |
| 28 ~WaiterList(); |
| 29 |
| 30 void AwakeWaitersForStateChange(MojoWaitFlags satisfied_flags, |
| 31 MojoWaitFlags satisfiable_flags); |
| 32 void CancelAllWaiters(); |
| 33 void AddWaiter(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result); |
| 34 void RemoveWaiter(Waiter* waiter); |
| 35 |
| 36 private: |
| 37 struct WaiterInfo { |
| 38 WaiterInfo(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result) |
| 39 : waiter(waiter), flags(flags), wake_result(wake_result) {} |
| 40 |
| 41 Waiter* waiter; |
| 42 MojoWaitFlags flags; |
| 43 MojoResult wake_result; |
| 44 }; |
| 45 typedef std::list<WaiterInfo> WaiterInfoList; |
| 46 |
| 47 WaiterInfoList waiters_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(WaiterList); |
| 50 }; |
| 51 |
| 52 } // namespace system |
| 53 } // namespace mojo |
| 54 |
| 55 #endif // MOJO_SYSTEM_WAITER_LIST_H_ |
OLD | NEW |