Diff
Modified: trunk/Source/WTF/ChangeLog (201683 => 201684)
--- trunk/Source/WTF/ChangeLog 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/ChangeLog 2016-06-04 20:53:25 UTC (rev 201684)
@@ -1,3 +1,23 @@
+2016-06-04 Anders Carlsson <[email protected]>
+
+ Get rid of WorkItemWin
+ https://bugs.webkit.org/show_bug.cgi?id=158381
+
+ Reviewed by Sam Weinig.
+
+ * wtf/PlatformWin.cmake:
+ * wtf/WorkQueue.h:
+ * wtf/win/WorkItemWin.cpp: Removed.
+ (WTF::WorkItemWin::WorkItemWin): Deleted.
+ (WTF::WorkItemWin::create): Deleted.
+ (WTF::WorkItemWin::~WorkItemWin): Deleted.
+ * wtf/win/WorkItemWin.h: Removed.
+ (WTF::WorkItemWin::function): Deleted.
+ (WTF::WorkItemWin::queue): Deleted.
+ * wtf/win/WorkQueueWin.cpp:
+ (WTF::WorkQueue::performWorkOnRegisteredWorkThread):
+ (WTF::WorkQueue::dispatch):
+
2016-06-03 Anders Carlsson <[email protected]>
Get rid of HANDLE registration code in WorkQueueWin
Modified: trunk/Source/WTF/wtf/PlatformWin.cmake (201683 => 201684)
--- trunk/Source/WTF/wtf/PlatformWin.cmake 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/wtf/PlatformWin.cmake 2016-06-04 20:53:25 UTC (rev 201684)
@@ -8,7 +8,6 @@
win/MainThreadWin.cpp
win/RunLoopWin.cpp
- win/WorkItemWin.cpp
win/WorkQueueWin.cpp
)
Modified: trunk/Source/WTF/wtf/WorkQueue.h (201683 => 201684)
--- trunk/Source/WTF/wtf/WorkQueue.h 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2016-06-04 20:53:25 UTC (rev 201684)
@@ -43,9 +43,7 @@
#endif
#if USE(WINDOWS_EVENT_LOOP)
-#include <wtf/HashMap.h>
#include <wtf/Vector.h>
-#include <wtf/win/WorkItemWin.h>
#endif
#if USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
@@ -109,8 +107,8 @@
#elif USE(WINDOWS_EVENT_LOOP)
volatile LONG m_isWorkThreadRegistered;
- Mutex m_workItemQueueLock;
- Vector<RefPtr<WorkItemWin>> m_workItemQueue;
+ Mutex m_functionQueueLock;
+ Vector<NoncopyableFunction<void ()>> m_functionQueue;
HANDLE m_timerQueue;
#elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
Deleted: trunk/Source/WTF/wtf/win/WorkItemWin.cpp (201683 => 201684)
--- trunk/Source/WTF/wtf/win/WorkItemWin.cpp 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/wtf/win/WorkItemWin.cpp 2016-06-04 20:53:25 UTC (rev 201684)
@@ -1,50 +0,0 @@
-/*
-* Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-* THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "config.h"
-#include "WorkItemWin.h"
-
-#include <Windows.h>
-#include <wtf/Threading.h>
-#include <wtf/WorkQueue.h>
-
-namespace WTF {
-
-WorkItemWin::WorkItemWin(NoncopyableFunction<void ()>&& function, WorkQueue* queue)
- : m_function(WTFMove(function))
- , m_queue(queue)
-{
-}
-
-RefPtr<WorkItemWin> WorkItemWin::create(NoncopyableFunction<void ()>&& function, WorkQueue* queue)
-{
- return adoptRef(new WorkItemWin(WTFMove(function), queue));
-}
-
-WorkItemWin::~WorkItemWin()
-{
-}
-
-} // namespace WTF
Deleted: trunk/Source/WTF/wtf/win/WorkItemWin.h (201683 => 201684)
--- trunk/Source/WTF/wtf/win/WorkItemWin.h 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/wtf/win/WorkItemWin.h 2016-06-04 20:53:25 UTC (rev 201684)
@@ -1,58 +0,0 @@
-/*
-* Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
-* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-* THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef WorkItemWin_h
-#define WorkItemWin_h
-
-#include <Windows.h>
-#include <functional>
-#include <wtf/FunctionDispatcher.h>
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadSafeRefCounted.h>
-
-namespace WTF {
-
-class WorkQueue;
-
-class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> {
-public:
- static RefPtr<WorkItemWin> create(NoncopyableFunction<void ()>&&, WorkQueue*);
- virtual ~WorkItemWin();
-
- NoncopyableFunction<void ()>& function() { return m_function; }
- WorkQueue* queue() const { return m_queue.get(); }
-
-protected:
- WorkItemWin(NoncopyableFunction<void ()>&&, WorkQueue*);
-
-private:
- NoncopyableFunction<void ()> m_function;
- RefPtr<WorkQueue> m_queue;
-};
-
-}
-
-#endif
Modified: trunk/Source/WTF/wtf/win/WorkQueueWin.cpp (201683 => 201684)
--- trunk/Source/WTF/wtf/win/WorkQueueWin.cpp 2016-06-04 19:26:24 UTC (rev 201683)
+++ trunk/Source/WTF/wtf/win/WorkQueueWin.cpp 2016-06-04 20:53:25 UTC (rev 201684)
@@ -28,7 +28,6 @@
#include <wtf/MathExtras.h>
#include <wtf/Threading.h>
-#include <wtf/win/WorkItemWin.h>
namespace WTF {
@@ -49,19 +48,19 @@
{
ASSERT(m_isWorkThreadRegistered);
- m_workItemQueueLock.lock();
+ m_functionQueueLock.lock();
- while (!m_workItemQueue.isEmpty()) {
- Vector<RefPtr<WorkItemWin>> workItemQueue;
- m_workItemQueue.swap(workItemQueue);
+ while (!m_functionQueue.isEmpty()) {
+ Vector<NoncopyableFunction<void ()>> functionQueue;
+ m_functionQueue.swap(functionQueue);
// Allow more work to be scheduled while we're not using the queue directly.
- m_workItemQueueLock.unlock();
- for (auto& workItem : workItemQueue) {
- workItem->function()();
+ m_functionQueueLock.unlock();
+ for (auto& function : functionQueue) {
+ function();
deref();
}
- m_workItemQueueLock.lock();
+ m_functionQueueLock.lock();
}
// One invariant we maintain is that any work scheduled while a work thread is registered will
@@ -69,7 +68,7 @@
// held so that no work can be scheduled while we're still registered.
unregisterAsWorkThread();
- m_workItemQueueLock.unlock();
+ m_functionQueueLock.unlock();
}
void WorkQueue::platformInitialize(const char* name, Type, QOS)
@@ -101,9 +100,9 @@
void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function)
{
- MutexLocker locker(m_workItemQueueLock);
+ MutexLocker locker(m_functionQueueLock);
ref();
- m_workItemQueue.append(WorkItemWin::create(WTFMove(function), this));
+ m_functionQueue.append(WTFMove(function));
// Spawn a work thread to perform the work we just added. As an optimization, we avoid
// spawning the thread if a work thread is already registered. This prevents multiple work