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

Side by Side Diff: third_party/WebKit/Source/platform/WaitableEvent.h

Issue 1682423002: Remove WebWaitableEvent and replace it with WaitableEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 4 years, 10 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
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
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 {
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, Manual };
47 53
48 // Specify the initial state on creation. 54 // Specify the initial state on creation.
49 enum class InitialState { NonSignaled, Signaled }; 55 enum class InitialState { NonSignaled, Signaled };
50 56
51 virtual ~WebWaitableEvent() {} 57 explicit WaitableEvent(ResetPolicy = ResetPolicy::Auto, InitialState = Initi alState::NonSignaled);
58
59 ~WaitableEvent();
52 60
53 // Puts the event in the un-signaled state. 61 // Puts the event in the un-signaled state.
54 virtual void reset() {} 62 void reset();
55 63
56 // Waits indefinitely for the event to be signaled. 64 // Waits indefinitely for the event to be signaled.
57 virtual void wait() {} 65 void wait();
58 66
59 // Puts the event in the signaled state. Causing any thread blocked on Wait 67 // 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 68 // to be woken up. The event state is reset to non-signaled after
61 // a waiting thread has been released. 69 // a waiting thread has been released.
62 virtual void signal() {} 70 void signal();
71
72 // Waits on multiple events and returns the index of the object that
73 // has been signaled. Any event objects given to this method must
74 // not deleted while this wait is happening.
75 static size_t waitMultiple(const WTF::Vector<WaitableEvent*>& events);
76
77 private:
78 WaitableEvent(const WaitableEvent&) = delete;
79 void operator=(const WaitableEvent&) = delete;
80
81 OwnPtr<base::WaitableEvent> m_impl;
63 }; 82 };
64 83
65 } // namespace blink 84 } // namespace blink
66 85
67 #endif // WebWaitableEvent_h 86 #endif // WaitableEvent_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/DEPS ('k') | third_party/WebKit/Source/platform/WaitableEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698