Index: mojo/public/cpp/system/event.cc |
diff --git a/mojo/public/cpp/system/event.cc b/mojo/public/cpp/system/event.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79028a975a4d0e7d7a8076779ba06cfd694c461f |
--- /dev/null |
+++ b/mojo/public/cpp/system/event.cc |
@@ -0,0 +1,33 @@ |
+// 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. |
+ |
+#include "mojo/public/cpp/system/event.h" |
+ |
+namespace mojo { |
+ |
+Event::Event() { |
+ mojo::MessagePipe pipe; |
+ signal_handle_ = std::move(pipe.handle0); |
+ wait_handle_ = std::move(pipe.handle1); |
+} |
+ |
+Event::~Event() {} |
+ |
+void Event::Signal() { |
+ MojoResult rv = mojo::WriteMessageRaw(signal_handle_.get(), nullptr, 0, |
+ nullptr, 0, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE); |
+ DCHECK_EQ(rv, MOJO_RESULT_OK); |
+} |
+ |
+void Event::Reset() { |
+ MojoResult rv = MOJO_RESULT_OK; |
+ while (rv == MOJO_RESULT_OK) { |
+ rv = mojo::ReadMessageRaw(wait_handle_.get(), nullptr, nullptr, nullptr, |
+ nullptr, MOJO_READ_MESSAGE_FLAG_NONE); |
+ } |
+ DCHECK_EQ(rv, MOJO_RESULT_SHOULD_WAIT); |
+} |
+ |
+} // namespace mojo |