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> |
11 | 11 |
12 #include "mojo/edk/system/system_impl_export.h" | |
13 #include "mojo/public/c/system/types.h" | 12 #include "mojo/public/c/system/types.h" |
14 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
15 | 14 |
16 namespace mojo { | 15 namespace mojo { |
17 namespace system { | 16 namespace system { |
18 | 17 |
19 class Awakable; | 18 class Awakable; |
20 struct HandleSignalsState; | 19 struct HandleSignalsState; |
21 | 20 |
22 // |AwakableList| tracks all the |Waiter|s that are waiting on a given | 21 // |AwakableList| tracks all the |Awakable|s (usually |Waiter|s) that are |
23 // handle/|Dispatcher|. There should be a |AwakableList| for each handle that | 22 // waiting on a given handle/|Dispatcher|. There should be a |AwakableList| for |
24 // can be waited on (in any way). In the simple case, the |AwakableList| is | 23 // each handle that can be waited on (in any way). In the simple case, the |
25 // owned by the |Dispatcher|, whereas in more complex cases it is owned by the | 24 // |AwakableList| is owned by the |Dispatcher|, whereas in more complex cases it |
26 // secondary object (see simple_dispatcher.* and the explanatory comment in | 25 // is owned by the secondary object (see simple_dispatcher.* and the explanatory |
27 // core.cc). This class is thread-unsafe (all concurrent access must be | 26 // comment in core.cc). This class is thread-unsafe (all concurrent access must |
28 // protected by some lock). | 27 // be protected by some lock). |
29 class MOJO_SYSTEM_IMPL_EXPORT AwakableList { | 28 class AwakableList { |
30 public: | 29 public: |
31 AwakableList(); | 30 AwakableList(); |
32 ~AwakableList(); | 31 ~AwakableList(); |
33 | 32 |
34 void AwakeForStateChange(const HandleSignalsState& state); | 33 void AwakeForStateChange(const HandleSignalsState& state); |
35 void CancelAll(); | 34 void CancelAll(); |
36 void Add(Awakable* awakable, MojoHandleSignals signals, uint32_t context); | 35 void Add(Awakable* awakable, MojoHandleSignals signals, uint32_t context); |
37 void Remove(Awakable* awakable); | 36 void Remove(Awakable* awakable); |
38 | 37 |
39 private: | 38 private: |
40 struct AwakeInfo { | 39 struct AwakeInfo { |
41 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint32_t context) | 40 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint32_t context) |
42 : awakable(awakable), signals(signals), context(context) {} | 41 : awakable(awakable), signals(signals), context(context) {} |
43 | 42 |
44 Awakable* awakable; | 43 Awakable* awakable; |
45 MojoHandleSignals signals; | 44 MojoHandleSignals signals; |
46 uint32_t context; | 45 uint32_t context; |
47 }; | 46 }; |
48 using AwakeInfoList = std::vector<AwakeInfo>; | 47 using AwakeInfoList = std::vector<AwakeInfo>; |
49 | 48 |
50 AwakeInfoList awakables_; | 49 AwakeInfoList awakables_; |
51 | 50 |
52 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); | 51 MOJO_DISALLOW_COPY_AND_ASSIGN(AwakableList); |
53 }; | 52 }; |
54 | 53 |
55 } // namespace system | 54 } // namespace system |
56 } // namespace mojo | 55 } // namespace mojo |
57 | 56 |
58 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ | 57 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ |
OLD | NEW |