Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move WorkQueue from WK2 to WTF
https://bugs.webkit.org/show_bug.cgi?id=141797

Reviewed by Anders Carlsson.

Source/WebKit2:

* CMakeLists.txt:
* DatabaseProcess/DatabaseProcess.h:
* Platform/IPC/Connection.h:
* Platform/WorkQueue.cpp: Removed.
* Platform/WorkQueue.h: Removed.
* Platform/efl/WorkQueueEfl.cpp: Removed.
* Platform/gtk/WorkQueueGtk.cpp: Removed.
* Platform/mac/WorkQueueMac.cpp: Removed.
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* Shared/Network/CustomProtocols/CustomProtocolManager.h:
* UIProcess/Launcher/ProcessLauncher.cpp:
* UIProcess/Storage/LocalStorageDatabase.cpp:
* UIProcess/Storage/LocalStorageDatabase.h:
* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
* UIProcess/Storage/LocalStorageDatabaseTracker.h:
* UIProcess/Storage/StorageManager.cpp:
* UIProcess/Storage/StorageManager.h:
* WebKit2.xcodeproj/project.pbxproj:

Source/WTF:

It may be useful in WebCore.

Windows implementation is still missing.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/PlatformGTK.cmake:
* wtf/WorkQueue.cpp: Copied from Source/WebKit2/Platform/WorkQueue.cpp.
* wtf/WorkQueue.h: Copied from Source/WebKit2/Platform/WorkQueue.h.
* wtf/cocoa: Added.
* wtf/cocoa/WorkQueueCocoa.cpp: Copied from Source/WebKit2/Platform/mac/WorkQueueMac.cpp.
* wtf/efl/WorkQueueEfl.cpp: Copied from Source/WebKit2/Platform/efl/WorkQueueEfl.cpp.
* wtf/gtk/WorkQueueGtk.cpp: Copied from Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp.


Canonical link: https://commits.webkit.org/159852@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
anttijk committed Feb 20, 2015
1 parent 673055f commit 0efebb0
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 44 deletions.
21 changes: 21 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,24 @@
2015-02-20 Antti Koivisto <antti@apple.com>

Move WorkQueue from WK2 to WTF
https://bugs.webkit.org/show_bug.cgi?id=141797

Reviewed by Anders Carlsson.

It may be useful in WebCore.

Windows implementation is still missing.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/PlatformGTK.cmake:
* wtf/WorkQueue.cpp: Copied from Source/WebKit2/Platform/WorkQueue.cpp.
* wtf/WorkQueue.h: Copied from Source/WebKit2/Platform/WorkQueue.h.
* wtf/cocoa: Added.
* wtf/cocoa/WorkQueueCocoa.cpp: Copied from Source/WebKit2/Platform/mac/WorkQueueMac.cpp.
* wtf/efl/WorkQueueEfl.cpp: Copied from Source/WebKit2/Platform/efl/WorkQueueEfl.cpp.
* wtf/gtk/WorkQueueGtk.cpp: Copied from Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp.

2015-02-13 Gyuyoung Kim <gyuyoung.kim@samsung.com>

[EFL] Enable bmalloc for EFL port
Expand Down
20 changes: 20 additions & 0 deletions Source/WTF/WTF.xcodeproj/project.pbxproj
Expand Up @@ -282,6 +282,9 @@
CE73E02519DCB7AB00580D5C /* XPCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE73E02419DCB7AB00580D5C /* XPCSPI.h */; };
E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
E15556F618A0CC18006F48FB /* CryptographicUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E15556F418A0CC18006F48FB /* CryptographicUtilities.h */; };
E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
E4A0AD3A1A96245500536DF6 /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A0AD381A96245500536DF6 /* WorkQueue.h */; };
E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; };
FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; };
Expand Down Expand Up @@ -578,6 +581,9 @@
CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; };
E15556F418A0CC18006F48FB /* CryptographicUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicUtilities.h; sourceTree = "<group>"; };
E4A0AD371A96245500536DF6 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
E4A0AD381A96245500536DF6 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; };
EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; };
FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; };
FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -698,6 +704,7 @@
isa = PBXGroup;
children = (
2CDED0F018115C3F004DBA70 /* cf */,
E4A0AD3B1A96251900536DF6 /* cocoa */,
A8A47281151A825A004123FF /* dtoa */,
1FA47C87152502DA00568D1B /* ios */,
A8A472C4151A825A004123FF /* mac */,
Expand Down Expand Up @@ -896,6 +903,8 @@
A8A47371151A825B004123FF /* VectorTraits.h */,
A8A47372151A825B004123FF /* VMTags.h */,
974CFC8D16A4F327006D5404 /* WeakPtr.h */,
E4A0AD371A96245500536DF6 /* WorkQueue.cpp */,
E4A0AD381A96245500536DF6 /* WorkQueue.h */,
A8A4737A151A825B004123FF /* WTFThreadData.cpp */,
A8A4737B151A825B004123FF /* WTFThreadData.h */,
);
Expand Down Expand Up @@ -1031,6 +1040,14 @@
path = spi;
sourceTree = "<group>";
};
E4A0AD3B1A96251900536DF6 /* cocoa */ = {
isa = PBXGroup;
children = (
E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */,
);
path = cocoa;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -1221,6 +1238,7 @@
A8A4747F151A825B004123FF /* VectorTraits.h in Headers */,
A8A47480151A825B004123FF /* VMTags.h in Headers */,
974CFC8E16A4F327006D5404 /* WeakPtr.h in Headers */,
E4A0AD3A1A96245500536DF6 /* WorkQueue.h in Headers */,
1FA47C8B152502DA00568D1B /* WebCoreThread.h in Headers */,
A8A47446151A825B004123FF /* WTFString.h in Headers */,
A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
Expand Down Expand Up @@ -1350,6 +1368,7 @@
A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
0F885E0F1845AEA900F1E3FA /* FastBitVector.cpp in Sources */,
E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */,
A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
A8A473C3151A825B004123FF /* FastMalloc.cpp in Sources */,
A5BA15FA182435A600A82E69 /* AtomicStringCF.cpp in Sources */,
Expand Down Expand Up @@ -1378,6 +1397,7 @@
2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */,
1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */,
A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */,
1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */,
1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */,
A748745217A0BDAE00FA04CB /* SixCharacterHash.cpp in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions Source/WTF/wtf/CMakeLists.txt
Expand Up @@ -110,6 +110,7 @@ set(WTF_HEADERS
Vector.h
VectorTraits.h
WTFThreadData.h
WorkQueue.h
WeakPtr.h
dtoa.h

Expand Down Expand Up @@ -184,6 +185,7 @@ set(WTF_SOURCES
StringPrintStream.cpp
Threading.cpp
WTFThreadData.cpp
WorkQueue.cpp
dtoa.cpp

dtoa/bignum-dtoa.cc
Expand Down
1 change: 1 addition & 0 deletions Source/WTF/wtf/PlatformGTK.cmake
Expand Up @@ -6,6 +6,7 @@ list(APPEND WTF_SOURCES

gtk/MainThreadGtk.cpp
gtk/RunLoopGtk.cpp
gtk/WorkQueueGtk.cpp
)

list(APPEND WTF_LIBRARIES
Expand Down
Expand Up @@ -26,6 +26,8 @@
#include "config.h"
#include "WorkQueue.h"

namespace WTF {

Ref<WorkQueue> WorkQueue::create(const char* name, Type type, QOS qos)
{
return adoptRef(*new WorkQueue(name, type, qos));
Expand All @@ -40,3 +42,5 @@ WorkQueue::~WorkQueue()
{
platformInvalidate();
}

}
24 changes: 12 additions & 12 deletions Source/WebKit2/Platform/WorkQueue.h → Source/WTF/wtf/WorkQueue.h
Expand Up @@ -27,22 +27,16 @@
#ifndef WorkQueue_h
#define WorkQueue_h

#if OS(DARWIN)
#include <dispatch/dispatch.h>
#endif

#include <chrono>
#include <functional>
#include <wtf/Forward.h>
#include <wtf/FunctionDispatcher.h>
#include <wtf/Functional.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/Threading.h>
#include <wtf/Vector.h>

#if PLATFORM(GTK) || PLATFORM(EFL)
#include "PlatformProcessIdentifier.h"
#if OS(DARWIN)
#include <dispatch/dispatch.h>
#endif

#if PLATFORM(GTK)
Expand All @@ -52,6 +46,8 @@
#include <DispatchQueueEfl.h>
#endif

namespace WTF {

class WorkQueue final : public FunctionDispatcher {
public:
enum class Type {
Expand All @@ -66,11 +62,11 @@ class WorkQueue final : public FunctionDispatcher {
Background
};

static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
virtual ~WorkQueue();

virtual void dispatch(std::function<void ()>) override;
void dispatchAfter(std::chrono::nanoseconds, std::function<void ()>);
WTF_EXPORT_PRIVATE virtual void dispatch(std::function<void ()>) override;
WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, std::function<void ()>);

#if OS(DARWIN)
dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
Expand Down Expand Up @@ -102,4 +98,8 @@ class WorkQueue final : public FunctionDispatcher {
#endif
};

#endif // WorkQueue_h
}

using WTF::WorkQueue;

#endif
Expand Up @@ -26,6 +26,8 @@
#include "config.h"
#include "WorkQueue.h"

namespace WTF {

void WorkQueue::dispatch(std::function<void ()> function)
{
ref();
Expand Down Expand Up @@ -67,6 +69,8 @@ void WorkQueue::platformInitialize(const char* name, Type type, QOS qos)
dispatch_queue_attr_t attr = type == Type::Concurrent ? DISPATCH_QUEUE_CONCURRENT : DISPATCH_QUEUE_SERIAL;
#if HAVE(QOS_CLASSES)
attr = dispatch_queue_attr_make_with_qos_class(attr, dispatchQOSClass(qos), 0);
#else
UNUSED_PARAM(qos);
#endif
m_dispatchQueue = dispatch_queue_create(name, attr);
dispatch_set_context(m_dispatchQueue, this);
Expand All @@ -76,3 +80,5 @@ void WorkQueue::platformInvalidate()
{
dispatch_release(m_dispatchQueue);
}

}
File renamed without changes.
Expand Up @@ -29,6 +29,9 @@
#include "WorkQueue.h"

#include <gio/gio.h>
#include <string.h>

namespace WTF {

static const size_t kVisualStudioThreadNameLimit = 31;

Expand Down Expand Up @@ -113,3 +116,5 @@ void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, std::function<v
GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy("[WebKit] WorkQueue::dispatchAfter", WTF::move(function),
std::chrono::duration_cast<std::chrono::milliseconds>(duration), G_PRIORITY_DEFAULT, [this] { deref(); }, m_eventContext.get());
}

}
1 change: 0 additions & 1 deletion Source/WebKit2/CMakeLists.txt
Expand Up @@ -181,7 +181,6 @@ set(WebKit2_SOURCES

Platform/Logging.cpp
Platform/Module.cpp
Platform/WorkQueue.cpp

Platform/IPC/ArgumentCoders.cpp
Platform/IPC/ArgumentDecoder.cpp
Expand Down
27 changes: 27 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,30 @@
2015-02-20 Antti Koivisto <antti@apple.com>

Move WorkQueue from WK2 to WTF
https://bugs.webkit.org/show_bug.cgi?id=141797

Reviewed by Anders Carlsson.

* CMakeLists.txt:
* DatabaseProcess/DatabaseProcess.h:
* Platform/IPC/Connection.h:
* Platform/WorkQueue.cpp: Removed.
* Platform/WorkQueue.h: Removed.
* Platform/efl/WorkQueueEfl.cpp: Removed.
* Platform/gtk/WorkQueueGtk.cpp: Removed.
* Platform/mac/WorkQueueMac.cpp: Removed.
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* Shared/Network/CustomProtocols/CustomProtocolManager.h:
* UIProcess/Launcher/ProcessLauncher.cpp:
* UIProcess/Storage/LocalStorageDatabase.cpp:
* UIProcess/Storage/LocalStorageDatabase.h:
* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
* UIProcess/Storage/LocalStorageDatabaseTracker.h:
* UIProcess/Storage/StorageManager.cpp:
* UIProcess/Storage/StorageManager.h:
* WebKit2.xcodeproj/project.pbxproj:

2015-02-20 Carlos Garcia Campos <cgarcia@igalia.com>

[WK2][GTK] Fix the build after r180362
Expand Down
2 changes: 0 additions & 2 deletions Source/WebKit2/DatabaseProcess/DatabaseProcess.h
Expand Up @@ -33,8 +33,6 @@
#include "WebOriginDataManagerSupplement.h"
#include <wtf/NeverDestroyed.h>

class WorkQueue;

namespace WebKit {

class AsyncTask;
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit2/Platform/IPC/Connection.h
Expand Up @@ -33,11 +33,12 @@
#include "MessageEncoder.h"
#include "MessageReceiver.h"
#include "ProcessType.h"
#include "WorkQueue.h"
#include <atomic>
#include <condition_variable>
#include <wtf/Deque.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/WorkQueue.h>
#include <wtf/text/CString.h>

#if OS(DARWIN)
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit2/PlatformEfl.cmake
Expand Up @@ -11,7 +11,6 @@ list(APPEND WebKit2_SOURCES
Platform/efl/DispatchQueueEfl.cpp
Platform/efl/LoggingEfl.cpp
Platform/efl/ModuleEfl.cpp
Platform/efl/WorkQueueEfl.cpp

Platform/unix/SharedMemoryUnix.cpp

Expand Down
3 changes: 0 additions & 3 deletions Source/WebKit2/PlatformGTK.cmake
Expand Up @@ -30,7 +30,6 @@ list(APPEND WebKit2_SOURCES

Platform/gtk/LoggingGtk.cpp
Platform/gtk/ModuleGtk.cpp
Platform/gtk/WorkQueueGtk.cpp

Platform/unix/SharedMemoryUnix.cpp

Expand Down Expand Up @@ -624,7 +623,6 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)
list(APPEND PluginProcessGTK2_SOURCES
Platform/Logging.cpp
Platform/Module.cpp
Platform/WorkQueue.cpp

Platform/IPC/ArgumentCoders.cpp
Platform/IPC/ArgumentDecoder.cpp
Expand All @@ -643,7 +641,6 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)

Platform/gtk/LoggingGtk.cpp
Platform/gtk/ModuleGtk.cpp
Platform/gtk/WorkQueueGtk.cpp

Platform/unix/SharedMemoryUnix.cpp

Expand Down
Expand Up @@ -29,7 +29,7 @@
#include "Connection.h"
#include "NetworkProcessSupplement.h"
#include "WebProcessSupplement.h"
#include "WorkQueue.h"
#include <wtf/WorkQueue.h>
#include <wtf/text/WTFString.h>

#if PLATFORM(COCOA)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
Expand Up @@ -26,8 +26,8 @@
#include "config.h"
#include "ProcessLauncher.h"

#include "WorkQueue.h"
#include <wtf/StdLibExtras.h>
#include <wtf/StdLibExtras.h>
#include <wtf/WorkQueue.h>

namespace WebKit {

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp
Expand Up @@ -27,14 +27,14 @@
#include "LocalStorageDatabase.h"

#include "LocalStorageDatabaseTracker.h"
#include "WorkQueue.h"
#include <WebCore/FileSystem.h>
#include <WebCore/SQLiteStatement.h>
#include <WebCore/SQLiteTransaction.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/StorageMap.h>
#include <WebCore/SuddenTermination.h>
#include <wtf/PassRefPtr.h>
#include <wtf/WorkQueue.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>

Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h
Expand Up @@ -31,8 +31,7 @@
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>

class WorkQueue;
#include <wtf/WorkQueue.h>

namespace WebCore {
class SecurityOrigin;
Expand Down
Expand Up @@ -27,11 +27,11 @@
#include "LocalStorageDatabaseTracker.h"

#include "LocalStorageDetails.h"
#include "WorkQueue.h"
#include <WebCore/FileSystem.h>
#include <WebCore/SQLiteStatement.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/TextEncoding.h>
#include <wtf/WorkQueue.h>
#include <wtf/text/CString.h>

using namespace WebCore;
Expand Down

0 comments on commit 0efebb0

Please sign in to comment.