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

Side by Side Diff: mojo/public/cpp/system/event.cc

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 unified diff | Download patch
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 "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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698