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

Unified Diff: mojo/edk/system/channel.h

Issue 1530443005: EDK: Add PlatformHandleWatcher to Channel (and ChannelManager) classes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/edk/system/channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.h
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h
index 4ec69fe50fc98cb08775b45d88e45745fe433dde..e052f1e926119f4492b9aaa117b7e01f39f18cc3 100644
--- a/mojo/edk/system/channel.h
+++ b/mojo/edk/system/channel.h
@@ -11,6 +11,7 @@
#include <unordered_map>
#include "mojo/edk/platform/scoped_platform_handle.h"
+#include "mojo/edk/platform/task_runner.h"
#include "mojo/edk/system/channel_endpoint.h"
#include "mojo/edk/system/channel_endpoint_id.h"
#include "mojo/edk/system/incoming_endpoint.h"
@@ -30,22 +31,22 @@ namespace embedder {
class PlatformSupport;
}
+namespace platform {
+class PlatformHandleWatcher;
+}
+
namespace system {
class ChannelEndpointClient;
class ChannelManager;
class MessageInTransitQueue;
-// This class is mostly thread-safe. It must be created on an I/O thread.
-// |Init()| must be called on that same thread before it becomes thread-safe (in
-// particular, before references are given to any other thread) and |Shutdown()|
-// must be called on that same thread before destruction. Its public methods are
-// otherwise thread-safe. (Many private methods are restricted to the creation
-// thread.) It may be destroyed on any thread, in the sense that the last
-// reference to it may be released on any thread, with the proviso that
-// |Shutdown()| must have been called first (so the pattern is that a "main"
-// reference is kept on its creation thread and is released after |Shutdown()|
-// is called, but other threads may have temporarily "dangling" references).
+// This class is mostly thread-safe. It may be created and destroyed on any
+// thread. However, |Init()| must be called on an I/O thread before other
+// methods are called. Before destruction, |Shutdown()| must be called on that
+// same thread, after which other methods may not be called. Subject to these
+// restrictions, its public methods are otherwise thread-safe. (Many private
+// methods are restricted to the I/O thread.)
//
// Note the lock order (in order of allowable acquisition):
// |ChannelEndpointClient| (e.g., |MessagePipe|), |ChannelEndpoint|, |Channel|.
@@ -56,10 +57,12 @@ class Channel final : public util::RefCountedThreadSafe<Channel>,
public:
// Note: Use |util::MakeRefCounted<Channel>()|.
- // This must be called on the creation thread before any other methods are
- // called, and before references to this object are given to any other
- // threads. |raw_channel| should be uninitialized.
- void Init(std::unique_ptr<RawChannel> raw_channel) MOJO_NOT_THREAD_SAFE;
+ // This must be called on an I/O thread before any other methods are called.
+ // |io_task_runner| and |io_watcher| should be for this thread. |raw_channel|
+ // should be uninitialized.
+ void Init(util::RefPtr<platform::TaskRunner>&& io_task_runner,
+ platform::PlatformHandleWatcher* io_watcher,
+ std::unique_ptr<RawChannel> raw_channel) MOJO_NOT_THREAD_SAFE;
// Sets the channel manager associated with this channel. This should be set
// at most once and only called before |WillShutdownSoon()| (and
« no previous file with comments | « no previous file | mojo/edk/system/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698