| 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_SYSTEM_DISPATCHER_H_ | 5 #ifndef MOJO_SYSTEM_DISPATCHER_H_ |
| 6 #define MOJO_SYSTEM_DISPATCHER_H_ | 6 #define MOJO_SYSTEM_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "mojo/public/system/core.h" | 13 #include "mojo/public/system/core.h" |
| 14 #include "mojo/public/system/system_export.h" | 14 #include "mojo/system/system_impl_export.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace system { | 17 namespace system { |
| 18 | 18 |
| 19 class CoreImpl; | 19 class CoreImpl; |
| 20 class Waiter; | 20 class Waiter; |
| 21 | 21 |
| 22 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular | 22 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular |
| 23 // handle. This includes most (all?) primitives except for |MojoWait...()|. This | 23 // handle. This includes most (all?) primitives except for |MojoWait...()|. This |
| 24 // object is thread-safe, with its state being protected by a single lock | 24 // object is thread-safe, with its state being protected by a single lock |
| 25 // |lock_|, which is also made available to implementation subclasses (via the | 25 // |lock_|, which is also made available to implementation subclasses (via the |
| 26 // |lock()| method). | 26 // |lock()| method). |
| 27 class MOJO_SYSTEM_EXPORT Dispatcher : | 27 class MOJO_SYSTEM_IMPL_EXPORT Dispatcher : |
| 28 public base::RefCountedThreadSafe<Dispatcher> { | 28 public base::RefCountedThreadSafe<Dispatcher> { |
| 29 public: | 29 public: |
| 30 // These methods implement the various primitives named |Mojo...()|. These | 30 // These methods implement the various primitives named |Mojo...()|. These |
| 31 // take |lock_| and handle races with |Close()|. Then they call out to | 31 // take |lock_| and handle races with |Close()|. Then they call out to |
| 32 // subclasses' |...ImplNoLock()| methods (still under |lock_|), which actually | 32 // subclasses' |...ImplNoLock()| methods (still under |lock_|), which actually |
| 33 // implement the primitives. | 33 // implement the primitives. |
| 34 // NOTE(vtl): This puts a big lock around each dispatcher (i.e., handle), and | 34 // NOTE(vtl): This puts a big lock around each dispatcher (i.e., handle), and |
| 35 // prevents the various |...ImplNoLock()|s from releasing the lock as soon as | 35 // prevents the various |...ImplNoLock()|s from releasing the lock as soon as |
| 36 // possible. If this becomes an issue, we can rethink this. | 36 // possible. If this becomes an issue, we can rethink this. |
| 37 MojoResult Close(); | 37 MojoResult Close(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 mutable base::Lock lock_; | 127 mutable base::Lock lock_; |
| 128 bool is_closed_; | 128 bool is_closed_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 130 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace system | 133 } // namespace system |
| 134 } // namespace mojo | 134 } // namespace mojo |
| 135 | 135 |
| 136 #endif // MOJO_SYSTEM_DISPATCHER_H_ | 136 #endif // MOJO_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |