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

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

Issue 779503003: Extract Awakable from Waiter (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
(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_EDK_SYSTEM_AWAKABLE_LIST_H_
6 #define MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_
7
8 #include <stdint.h>
9
10 #include <list>
11
12 #include "base/macros.h"
13 #include "mojo/edk/system/system_impl_export.h"
14 #include "mojo/public/c/system/types.h"
15
16 namespace mojo {
17 namespace system {
18
19 class Awakable;
20 struct HandleSignalsState;
21
22 // |AwakableList| tracks all the |Waiter|s that are waiting on a given
23 // handle/|Dispatcher|. There should be a |AwakableList| for each handle that
24 // can
viettrungluu 2014/12/03 21:18:13 Please rewrap to 80 columns correctly.
Hajime Morrita 2014/12/03 21:44:09 Done.
25 // be waited on (in any way). In the simple case, the |AwakableList| is owned by
26 // the |Dispatcher|, whereas in more complex cases it is owned by the secondary
27 // object (see simple_dispatcher.* and the explanatory comment in core.cc). This
28 // class is thread-unsafe (all concurrent access must be protected by some
29 // lock).
30 class MOJO_SYSTEM_IMPL_EXPORT AwakableList {
31 public:
32 AwakableList();
33 ~AwakableList();
34
35 void AwakeForStateChange(const HandleSignalsState& state);
36 void CancelAll();
37 void AddWaiter(Awakable* awakable,
38 MojoHandleSignals signals,
39 uint32_t context);
40 void RemoveWaiter(Awakable* awakable);
41
42 void Add(Awakable* awakable, MojoHandleSignals signals, uint32_t context) {
viettrungluu 2014/12/03 21:18:13 Just rename AddWaiter and RemoveWaiter.
Hajime Morrita 2014/12/03 21:44:09 Oops. This should've been cleaned up :-(
43 AddWaiter(awakable, signals, context);
44 }
45 void Remove(Awakable* awakable) { RemoveWaiter(awakable); }
46
47 private:
48 struct AwakeInfo {
49 AwakeInfo(Awakable* awakable, MojoHandleSignals signals, uint32_t context)
50 : awakable(awakable), signals(signals), context(context) {}
51
52 Awakable* awakable;
53 MojoHandleSignals signals;
54 uint32_t context;
55 };
56 typedef std::list<AwakeInfo> AwakeInfoList;
57
58 AwakeInfoList awakables_;
59
60 DISALLOW_COPY_AND_ASSIGN(AwakableList);
61 };
62
63 } // namespace system
64 } // namespace mojo
65
66 #endif // MOJO_EDK_SYSTEM_AWAKABLE_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698