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

Side by Side Diff: ipc/mojo_event.h

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/ipc_sync_message_filter.cc ('k') | ipc/mojo_event.cc » ('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 #ifndef IPC_MOJO_EVENT_H_
6 #define IPC_MOJO_EVENT_H_
7
8 #include "base/macros.h"
9 #include "base/synchronization/lock.h"
10 #include "mojo/public/cpp/system/message_pipe.h"
11
12 namespace IPC {
13
14 // A MojoEvent is a simple wrapper around a Mojo message pipe which supports
15 // common WaitableEvent-like methods of Signal() and Reset(). This class exists
16 // to support the transition from legacy IPC to Mojo IPC and is not intended for
17 // general use outside of src/ipc. Unlike base::WaitableEvent, all MojoEvents
18 // must be manually reset.
19 class MojoEvent {
20 public:
21 // Constructs a new MojoEvent that is initially not signaled.
22 MojoEvent();
23
24 ~MojoEvent();
25
26 // Gets a Handle that can be waited on for this MojoEvent. When the Event is
27 // signaled, this handle will have |MOJO_HANDLE_SIGNAL_READABLE| satisfied.
28 const mojo::Handle& GetHandle() const { return wait_handle_.get(); }
29
30 void Signal();
31 void Reset();
32
33 private:
34 mojo::ScopedMessagePipeHandle signal_handle_;
35 mojo::ScopedMessagePipeHandle wait_handle_;
36
37 base::Lock lock_;
38 bool is_signaled_ = false;
39
40 DISALLOW_COPY_AND_ASSIGN(MojoEvent);
41 };
42
43 } // namespace IPC
44
45 #endif // IPC_MOJO_EVENT_H_
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message_filter.cc ('k') | ipc/mojo_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698