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 "ipc/mojo_event.h" | |
6 | |
7 namespace IPC { | |
8 | |
9 MojoEvent::MojoEvent() { | |
10 mojo::MessagePipe pipe; | |
11 signal_handle_ = std::move(pipe.handle0); | |
12 wait_handle_ = std::move(pipe.handle1); | |
13 } | |
14 | |
15 MojoEvent::~MojoEvent() {} | |
16 | |
17 void MojoEvent::Signal() { | |
18 base::AutoLock lock(lock_); | |
19 if (is_signaled_) | |
20 return; | |
21 is_signaled_ = true; | |
22 MojoResult rv = mojo::WriteMessageRaw( | |
23 signal_handle_.get(), nullptr, 0, nullptr, 0, | |
24 MOJO_WRITE_MESSAGE_FLAG_NONE); | |
25 CHECK_EQ(rv, MOJO_RESULT_OK); | |
26 } | |
27 | |
28 void MojoEvent::Reset() { | |
29 base::AutoLock lock(lock_); | |
30 if (!is_signaled_) | |
31 return; | |
32 is_signaled_ = false; | |
33 MojoResult rv = mojo::ReadMessageRaw( | |
34 wait_handle_.get(), nullptr, nullptr, nullptr, nullptr, | |
35 MOJO_READ_MESSAGE_FLAG_NONE); | |
36 CHECK_EQ(rv, MOJO_RESULT_OK); | |
37 } | |
38 | |
39 } // namespace IPC | |
OLD | NEW |