Chromium Code Reviews| 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 MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_ | |
| 6 #define MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "mojo/public/cpp/system/message_pipe.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 | |
| 13 // An Event is a simple wrapper around a Mojo message pipe which supports common | |
| 14 // WaitableEvent-like methods of Signal() and Reset(). All public methods on | |
| 15 // this object are safe to call from any thread as long as the object is still | |
| 16 // alive. | |
| 17 class Event { | |
| 18 public: | |
| 19 Event(); | |
|
yzshen1
2016/06/07 17:14:51
Please comment on the initial state, whether the s
Ken Rockot(use gerrit already)
2016/06/07 18:02:25
Done
| |
| 20 ~Event(); | |
| 21 | |
| 22 // Gets a Handle that can be waited on for this Event. Waiting may be done | |
| 23 // synchronously via MojoWait (or indirectly via a wait set), or | |
| 24 // asynchronously using a Watcher. When the Event is signaled, this handle | |
| 25 // will have |MOJO_HANDLE_SIGNAL_READABLE| satisfied. | |
| 26 const Handle& GetHandle() const { return wait_handle_.get(); } | |
| 27 | |
| 28 // Ensures that the Handle returned by |GetHandle()| has the | |
| 29 // |MOJO_HANDLE_SIGNAL_READABLE| signal satisfied. | |
| 30 void Signal(); | |
| 31 | |
| 32 // Ensures that the Handle returned by |GetHandle()| does NOT have the | |
| 33 // |MOJO_HANDLE_SIGNAL_READABLE| signal satisfied. | |
| 34 void Reset(); | |
| 35 | |
| 36 private: | |
| 37 ScopedMessagePipeHandle signal_handle_; | |
| 38 ScopedMessagePipeHandle wait_handle_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(Event); | |
| 41 }; | |
| 42 | |
| 43 } // namespace mojo | |
| 44 | |
| 45 #endif // MOJO_PUBLIC_CPP_SYSTEM_EVENT_H_ | |
| OLD | NEW |