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

Side by Side Diff: mojo/system/simple_dispatcher.h

Issue 23621056: Initial in-process implementation of some Mojo primitives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 years, 2 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 | Annotate | Revision Log
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_SYSTEM_SIMPLE_DISPATCHER_H_
6 #define MOJO_SYSTEM_SIMPLE_DISPATCHER_H_
7
8 #include <list>
9
10 #include "base/basictypes.h"
11 #include "mojo/system/dispatcher.h"
12 #include "mojo/system/waiter_list.h"
13
14 namespace mojo {
15 namespace system {
16
17 // A base class for simple dispatchers. "Simple" means that there's a one-to-one
18 // correspondence between handles and dispatchers (see the explanatory comment
19 // in core_impl.cc). This class implements the standard waiter-signalling
20 // mechanism in that case.
21 class SimpleDispatcher : public Dispatcher {
22 protected:
23 SimpleDispatcher();
24
25 friend class base::RefCountedThreadSafe<SimpleDispatcher>;
26 virtual ~SimpleDispatcher();
27
28 // To be called by subclasses when the state changes (so
29 // |SatisfiedFlagsNoLock()| and |SatisfiableFlagsNoLock()| should be checked
30 // again). Must be called under lock.
31 void StateChangedNoLock();
32
33 // These should return the wait flags that are satisfied by the object's
34 // current state and those that may eventually be satisfied by this object's
35 // state, respectively. They should be overridden by subclasses to reflect
36 // their notion of state. They are never called after the dispatcher has been
37 // closed. They are called under |lock_|.
38 virtual MojoWaitFlags SatisfiedFlagsNoLock() const = 0;
39 virtual MojoWaitFlags SatisfiableFlagsNoLock() const = 0;
40
41 // |Dispatcher| implementation/overrides:
42 virtual void CancelAllWaitersNoLock() OVERRIDE;
43 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter,
44 MojoWaitFlags flags,
45 MojoResult wake_result) OVERRIDE;
46 virtual void RemoveWaiterImplNoLock(Waiter* waiter) OVERRIDE;
47
48 private:
49 // Protected by |lock()|:
50 WaiterList waiter_list_;
51
52 DISALLOW_COPY_AND_ASSIGN(SimpleDispatcher);
53 };
54
55 } // namespace system
56 } // namespace mojo
57
58 #endif // MOJO_SYSTEM_SIMPLE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698