Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: mojo/edk/system/awakable_list.h

Issue 2750373002: Revert of Mojo: Armed Watchers (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/awakable_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "mojo/edk/system/system_impl_export.h" 14 #include "mojo/edk/system/system_impl_export.h"
15 #include "mojo/edk/system/watcher.h"
16 #include "mojo/edk/system/watcher_set.h"
15 #include "mojo/public/c/system/types.h" 17 #include "mojo/public/c/system/types.h"
16 18
17 namespace mojo { 19 namespace mojo {
18 namespace edk { 20 namespace edk {
19 21
20 class Awakable; 22 class Awakable;
21 struct HandleSignalsState; 23 struct HandleSignalsState;
22 24
23 // |AwakableList| tracks all the |Waiter|s that are waiting on a given 25 // |AwakableList| tracks all the |Waiter|s that are waiting on a given
24 // handle/|Dispatcher|. There should be a |AwakableList| for each handle that 26 // handle/|Dispatcher|. There should be a |AwakableList| for each handle that
25 // can be waited on (in any way). In the simple case, the |AwakableList| is 27 // can be waited on (in any way). In the simple case, the |AwakableList| is
26 // owned by the |Dispatcher|, whereas in more complex cases it is owned by the 28 // owned by the |Dispatcher|, whereas in more complex cases it is owned by the
27 // secondary object (see simple_dispatcher.* and the explanatory comment in 29 // secondary object (see simple_dispatcher.* and the explanatory comment in
28 // core.cc). This class is thread-unsafe (all concurrent access must be 30 // core.cc). This class is thread-unsafe (all concurrent access must be
29 // protected by some lock). 31 // protected by some lock).
30 class MOJO_SYSTEM_IMPL_EXPORT AwakableList { 32 class MOJO_SYSTEM_IMPL_EXPORT AwakableList {
31 public: 33 public:
32 AwakableList(); 34 AwakableList();
33 ~AwakableList(); 35 ~AwakableList();
34 36
35 void AwakeForStateChange(const HandleSignalsState& state); 37 void AwakeForStateChange(const HandleSignalsState& state);
36 void CancelAll(); 38 void CancelAll();
37 void Add(Awakable* awakable, MojoHandleSignals signals, uintptr_t context); 39 void Add(Awakable* awakable, MojoHandleSignals signals, uintptr_t context);
38 void Remove(Awakable* awakable); 40 void Remove(Awakable* awakable);
39 41
42 // Add and remove Watchers to this AwakableList.
43 MojoResult AddWatcher(MojoHandleSignals signals,
44 const Watcher::WatchCallback& callback,
45 uintptr_t context,
46 const HandleSignalsState& current_state);
47 MojoResult RemoveWatcher(uintptr_t context);
48
40 private: 49 private:
41 struct AwakeInfo { 50 struct AwakeInfo {
42 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uintptr_t context) 51 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uintptr_t context)
43 : awakable(awakable), signals(signals), context(context) {} 52 : awakable(awakable), signals(signals), context(context) {}
44 53
45 Awakable* awakable; 54 Awakable* awakable;
46 MojoHandleSignals signals; 55 MojoHandleSignals signals;
47 uintptr_t context; 56 uintptr_t context;
48 }; 57 };
49 using AwakeInfoList = std::vector<AwakeInfo>; 58 using AwakeInfoList = std::vector<AwakeInfo>;
50 59
51 AwakeInfoList awakables_; 60 AwakeInfoList awakables_;
52 61
62 // TODO: Remove AwakableList and instead use WatcherSet directly in
63 // dispatchers.
64 WatcherSet watchers_;
65
53 DISALLOW_COPY_AND_ASSIGN(AwakableList); 66 DISALLOW_COPY_AND_ASSIGN(AwakableList);
54 }; 67 };
55 68
56 } // namespace edk 69 } // namespace edk
57 } // namespace mojo 70 } // namespace mojo
58 71
59 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_ 72 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/awakable_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698