Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebWaitableEvent_h | 31 #ifndef WaitableEvent_h |
| 32 #define WebWaitableEvent_h | 32 #define WaitableEvent_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "wtf/OwnPtr.h" | |
| 36 #include "wtf/Vector.h" | |
| 37 | |
| 38 namespace base { | |
| 39 class WaitableEvent; | |
| 40 }; // namespace base | |
| 35 | 41 |
| 36 namespace blink { | 42 namespace blink { |
| 37 | 43 |
| 38 // Provides a thread synchronization that can be used to allow one thread to | 44 // Provides a thread synchronization that can be used to allow one thread to |
| 39 // wait until another thread to finish some work. | 45 // wait until another thread to finish some work. |
| 40 class WebWaitableEvent { | 46 class PLATFORM_EXPORT WaitableEvent { |
|
haraken
2016/02/11 00:53:52
I think WaitableEvent could be moved to wtf/, but
| |
| 41 public: | 47 public: |
| 42 // If ResetPolicy::Manual is specified on creation, to set the event state | 48 // If ResetPolicy::Manual is specified on creation, to set the event state |
| 43 // to non-signaled, a consumer must call reset(). Otherwise, the system | 49 // to non-signaled, a consumer must call reset(). Otherwise, the system |
| 44 // automatically resets the event state to non-signaled after a single | 50 // automatically resets the event state to non-signaled after a single |
| 45 // waiting thread has been released. | 51 // waiting thread has been released. |
| 46 enum class ResetPolicy { Auto, Manual }; | 52 enum class ResetPolicy { Auto, |
| 53 Manual }; | |
|
esprehn
2016/02/11 01:01:27
why did you wrap these?
| |
| 47 | 54 |
| 48 // Specify the initial state on creation. | 55 // Specify the initial state on creation. |
| 49 enum class InitialState { NonSignaled, Signaled }; | 56 enum class InitialState { NonSignaled, |
| 57 Signaled }; | |
| 50 | 58 |
| 51 virtual ~WebWaitableEvent() {} | 59 WaitableEvent(ResetPolicy = ResetPolicy::Auto, InitialState = InitialState:: NonSignaled); |
|
esprehn
2016/02/11 01:01:27
explicit
| |
| 60 | |
| 61 ~WaitableEvent(); | |
| 52 | 62 |
| 53 // Puts the event in the un-signaled state. | 63 // Puts the event in the un-signaled state. |
| 54 virtual void reset() {} | 64 void reset(); |
| 55 | 65 |
| 56 // Waits indefinitely for the event to be signaled. | 66 // Waits indefinitely for the event to be signaled. |
| 57 virtual void wait() {} | 67 void wait(); |
| 58 | 68 |
| 59 // Puts the event in the signaled state. Causing any thread blocked on Wait | 69 // Puts the event in the signaled state. Causing any thread blocked on Wait |
| 60 // to be woken up. The event state is reset to non-signaled after | 70 // to be woken up. The event state is reset to non-signaled after |
| 61 // a waiting thread has been released. | 71 // a waiting thread has been released. |
| 62 virtual void signal() {} | 72 void signal(); |
| 73 | |
| 74 // Waits on multiple events and returns the index of the object that | |
| 75 // has been signaled. Any event objects given to this method must | |
| 76 // not deleted while this wait is happening. | |
| 77 static size_t waitMultiple(const WTF::Vector<WaitableEvent*>& events); | |
| 78 | |
| 79 private: | |
| 80 WaitableEvent(const WaitableEvent&) = delete; | |
| 81 void operator=(const WaitableEvent&) = delete; | |
| 82 | |
| 83 OwnPtr<base::WaitableEvent> m_impl; | |
| 63 }; | 84 }; |
| 64 | 85 |
| 65 } // namespace blink | 86 } // namespace blink |
| 66 | 87 |
| 67 #endif // WebWaitableEvent_h | 88 #endif // WaitableEvent_h |
| OLD | NEW |