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

Side by Side Diff: ipc/mojo_event.cc

Issue 2754143005: Use WaitableEvents to wake up sync IPC waiting (Closed)
Patch Set: . Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « ipc/mojo_event.h ('k') | mojo/public/cpp/bindings/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « ipc/mojo_event.h ('k') | mojo/public/cpp/bindings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698