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 #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_ |
OLD | NEW |