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

Unified Diff: mojo/public/cpp/system/event.h

Issue 2033243003: Use Mojo pipes to signal sync IPC events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/system/BUILD.gn ('k') | mojo/public/cpp/system/event.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/event.h
diff --git a/mojo/public/cpp/system/event.h b/mojo/public/cpp/system/event.h
new file mode 100644
index 0000000000000000000000000000000000000000..1dca4fea3de9930674e59c78ab81b5a1229b4da7
--- /dev/null
+++ b/mojo/public/cpp/system/event.h
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_
+#define MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_
+
+#include "base/macros.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+
+namespace mojo {
+
+// An Event is a simple wrapper around a Mojo message pipe which supports common
+// WaitableEvent-like methods of Signal() and Reset(). All public methods on
+// this object are safe to call from any thread as long as the object is still
+// alive.
+class Event {
+ public:
+ Event();
yzshen1 2016/06/07 17:14:51 Please comment on the initial state, whether the s
Ken Rockot(use gerrit already) 2016/06/07 18:02:25 Done
+ ~Event();
+
+ // Gets a Handle that can be waited on for this Event. Waiting may be done
+ // synchronously via MojoWait (or indirectly via a wait set), or
+ // asynchronously using a Watcher. When the Event is signaled, this handle
+ // will have |MOJO_HANDLE_SIGNAL_READABLE| satisfied.
+ const Handle& GetHandle() const { return wait_handle_.get(); }
+
+ // Ensures that the Handle returned by |GetHandle()| has the
+ // |MOJO_HANDLE_SIGNAL_READABLE| signal satisfied.
+ void Signal();
+
+ // Ensures that the Handle returned by |GetHandle()| does NOT have the
+ // |MOJO_HANDLE_SIGNAL_READABLE| signal satisfied.
+ void Reset();
+
+ private:
+ ScopedMessagePipeHandle signal_handle_;
+ ScopedMessagePipeHandle wait_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(Event);
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_
« no previous file with comments | « mojo/public/cpp/system/BUILD.gn ('k') | mojo/public/cpp/system/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698