OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "mojo/public/cpp/system/event.h" |
| 6 |
| 7 namespace mojo { |
| 8 |
| 9 Event::Event() { |
| 10 mojo::MessagePipe pipe; |
| 11 signal_handle_ = std::move(pipe.handle0); |
| 12 wait_handle_ = std::move(pipe.handle1); |
| 13 } |
| 14 |
| 15 Event::~Event() {} |
| 16 |
| 17 void Event::Signal() { |
| 18 MojoResult rv = mojo::WriteMessageRaw(signal_handle_.get(), nullptr, 0, |
| 19 nullptr, 0, |
| 20 MOJO_WRITE_MESSAGE_FLAG_NONE); |
| 21 DCHECK_EQ(rv, MOJO_RESULT_OK); |
| 22 } |
| 23 |
| 24 void Event::Reset() { |
| 25 MojoResult rv = MOJO_RESULT_OK; |
| 26 while (rv == MOJO_RESULT_OK) { |
| 27 rv = mojo::ReadMessageRaw(wait_handle_.get(), nullptr, nullptr, nullptr, |
| 28 nullptr, MOJO_READ_MESSAGE_FLAG_NONE); |
| 29 } |
| 30 DCHECK_EQ(rv, MOJO_RESULT_SHOULD_WAIT); |
| 31 } |
| 32 |
| 33 } // namespace mojo |
OLD | NEW |