Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (218815 => 218816)
--- trunk/Source/_javascript_Core/ChangeLog 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1,3 +1,14 @@
+2017-06-26 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread::create(obsolete things) API since we can use lambda
+ https://bugs.webkit.org/show_bug.cgi?id=173825
+
+ Reviewed by Saam Barati.
+
+ * jsc.cpp:
+ (startTimeoutThreadIfNeeded):
+ (timeoutThreadMain): Deleted.
+
2017-06-26 Konstantin Tokarev <[email protected]>
Unreviewed, add missing header for CLoop
Modified: trunk/Source/_javascript_Core/jsc.cpp (218815 => 218816)
--- trunk/Source/_javascript_Core/jsc.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/_javascript_Core/jsc.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -3173,14 +3173,6 @@
static double s_desiredTimeout;
static double s_timeoutMultiplier = 1.0;
-static NO_RETURN_DUE_TO_CRASH void timeoutThreadMain(void*)
-{
- Seconds timeoutDuration(s_desiredTimeout * s_timeoutMultiplier);
- sleep(timeoutDuration);
- dataLog("Timed out after ", timeoutDuration, " seconds!\n");
- CRASH();
-}
-
static void startTimeoutThreadIfNeeded()
{
if (char* timeoutString = getenv("JSCTEST_timeout")) {
@@ -3187,8 +3179,14 @@
if (sscanf(timeoutString, "%lf", &s_desiredTimeout) != 1) {
dataLog("WARNING: timeout string is malformed, got ", timeoutString,
" but expected a number. Not using a timeout.\n");
- } else
- Thread::create(timeoutThreadMain, 0, "jsc Timeout Thread");
+ } else {
+ Thread::create("jsc Timeout Thread", [] () {
+ Seconds timeoutDuration(s_desiredTimeout * s_timeoutMultiplier);
+ sleep(timeoutDuration);
+ dataLog("Timed out after ", timeoutDuration, " seconds!\n");
+ CRASH();
+ });
+ }
}
}
Modified: trunk/Source/WTF/ChangeLog (218815 => 218816)
--- trunk/Source/WTF/ChangeLog 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/ChangeLog 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1,3 +1,24 @@
+2017-06-26 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread::create(obsolete things) API since we can use lambda
+ https://bugs.webkit.org/show_bug.cgi?id=173825
+
+ Reviewed by Saam Barati.
+
+ Thread::create(ThreadFunction, void* data, const char* name) is a bit old API.
+ Since we have C++ lambda, the above API is simply unnecessary. And C++ lambda
+ based one is better since the above API needs casting data to and from void*.
+
+ * wtf/Function.h:
+ Avoid ambiguity.
+ * wtf/ParallelJobsGeneric.cpp:
+ (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
+ (WTF::ParallelEnvironment::ThreadPrivate::workerThread): Deleted.
+ * wtf/ParallelJobsGeneric.h:
+ * wtf/Threading.cpp:
+ * wtf/ThreadingWin.cpp:
+ (WTF::createThread):
+
2017-06-25 Yusuke Suzuki <[email protected]>
initializeThreading() [first] causes WTFCrash due to maxSingleAllocationSize not being initialized
Modified: trunk/Source/WTF/wtf/Function.h (218815 => 218816)
--- trunk/Source/WTF/wtf/Function.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/wtf/Function.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -38,7 +38,7 @@
Function() = default;
Function(std::nullptr_t) { }
- template<typename CallableType, class = typename std::enable_if<std::is_rvalue_reference<CallableType&&>::value>::type>
+ template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Function(CallableType&& callable)
: m_callableWrapper(std::make_unique<CallableWrapper<CallableType>>(WTFMove(callable)))
{
@@ -59,7 +59,7 @@
explicit operator bool() const { return !!m_callableWrapper; }
- template<typename CallableType, class = typename std::enable_if<std::is_rvalue_reference<CallableType&&>::value>::type>
+ template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Function& operator=(CallableType&& callable)
{
m_callableWrapper = std::make_unique<CallableWrapper<CallableType>>(WTFMove(callable));
Modified: trunk/Source/WTF/wtf/ParallelJobsGeneric.cpp (218815 => 218816)
--- trunk/Source/WTF/wtf/ParallelJobsGeneric.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/wtf/ParallelJobsGeneric.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -93,9 +93,23 @@
return false;
}
- if (!m_thread)
- m_thread = Thread::create(&ParallelEnvironment::ThreadPrivate::workerThread, this, "Parallel worker");
+ if (!m_thread) {
+ m_thread = Thread::create("Parallel worker", [this] {
+ LockHolder lock(m_mutex);
+ while (m_thread) {
+ if (m_running) {
+ (*m_threadFunction)(m_parameters);
+ m_running = false;
+ m_parent = 0;
+ m_threadCondition.notifyOne();
+ }
+
+ m_threadCondition.wait(m_mutex);
+ }
+ });
+ }
+
if (m_thread)
m_parent = parent;
@@ -121,22 +135,5 @@
m_threadCondition.wait(m_mutex);
}
-void ParallelEnvironment::ThreadPrivate::workerThread(void* threadData)
-{
- ThreadPrivate* sharedThread = reinterpret_cast<ThreadPrivate*>(threadData);
- LockHolder lock(sharedThread->m_mutex);
-
- while (sharedThread->m_thread) {
- if (sharedThread->m_running) {
- (*sharedThread->m_threadFunction)(sharedThread->m_parameters);
- sharedThread->m_running = false;
- sharedThread->m_parent = 0;
- sharedThread->m_threadCondition.notifyOne();
- }
-
- sharedThread->m_threadCondition.wait(sharedThread->m_mutex);
- }
-}
-
} // namespace WTF
#endif // ENABLE(THREADING_GENERIC)
Modified: trunk/Source/WTF/wtf/ParallelJobsGeneric.h (218815 => 218816)
--- trunk/Source/WTF/wtf/ParallelJobsGeneric.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/wtf/ParallelJobsGeneric.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -64,8 +64,6 @@
return adoptRef(*new ThreadPrivate());
}
- static void workerThread(void*);
-
private:
RefPtr<Thread> m_thread;
bool m_running { false };
Modified: trunk/Source/WTF/wtf/Threading.cpp (218815 => 218816)
--- trunk/Source/WTF/wtf/Threading.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/wtf/Threading.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -111,13 +111,6 @@
return Thread::createInternal(threadEntryPoint, context, name);
}
-RefPtr<Thread> Thread::create(ThreadFunction entryPoint, void* data, const char* name)
-{
- return Thread::create(name, [entryPoint, data] {
- entryPoint(data);
- });
-}
-
void Thread::didExit()
{
std::unique_lock<std::mutex> locker(m_mutex);
Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (218815 => 218816)
--- trunk/Source/WTF/wtf/ThreadingWin.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -516,7 +516,9 @@
// Remove this workaround code when <rdar://problem/31793213> is fixed.
ThreadIdentifier createThread(ThreadFunction function, void* data, const char* threadName)
{
- return Thread::create(function, data, threadName)->id();
+ return Thread::create(threadName, [function, data] {
+ function(data);
+ })->id();
}
int waitForThreadCompletion(ThreadIdentifier threadID)
Modified: trunk/Source/WebCore/ChangeLog (218815 => 218816)
--- trunk/Source/WebCore/ChangeLog 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/ChangeLog 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1,3 +1,66 @@
+2017-06-26 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread::create(obsolete things) API since we can use lambda
+ https://bugs.webkit.org/show_bug.cgi?id=173825
+
+ Reviewed by Saam Barati.
+
+ No behavior change.
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::IDBServer):
+ (WebCore::IDBServer::IDBServer::databaseThreadEntry): Deleted.
+ * Modules/indexeddb/server/IDBServer.h:
+ * Modules/webaudio/AsyncAudioDecoder.cpp:
+ (WebCore::AsyncAudioDecoder::AsyncAudioDecoder):
+ (WebCore::AsyncAudioDecoder::threadEntry): Deleted.
+ * Modules/webaudio/AsyncAudioDecoder.h:
+ * Modules/webaudio/OfflineAudioDestinationNode.cpp:
+ (WebCore::OfflineAudioDestinationNode::startRendering):
+ (WebCore::OfflineAudioDestinationNode::offlineRenderEntry): Deleted.
+ * Modules/webaudio/OfflineAudioDestinationNode.h:
+ * Modules/webdatabase/DatabaseThread.cpp:
+ (WebCore::DatabaseThread::start):
+ (WebCore::DatabaseThread::databaseThreadStart): Deleted.
+ * Modules/webdatabase/DatabaseThread.h:
+ * bindings/js/GCController.cpp:
+ (WebCore::collect):
+ (WebCore::GCController::gcTimerFired):
+ (WebCore::GCController::garbageCollectOnAlternateThreadForDebugging):
+ * loader/icon/IconDatabase.cpp:
+ (WebCore::IconDatabase::open):
+ (WebCore::IconDatabase::iconDatabaseSyncThreadStart): Deleted.
+ * loader/icon/IconDatabase.h:
+ * page/ResourceUsageThread.cpp:
+ (WebCore::ResourceUsageThread::createThreadIfNeeded):
+ (WebCore::ResourceUsageThread::threadCallback): Deleted.
+ * page/ResourceUsageThread.h:
+ * page/scrolling/ScrollingThread.cpp:
+ (WebCore::ScrollingThread::createThreadIfNeeded):
+ (WebCore::ScrollingThread::threadCallback): Deleted.
+ (WebCore::ScrollingThread::threadBody): Deleted.
+ * page/scrolling/ScrollingThread.h:
+ * platform/audio/HRTFDatabaseLoader.cpp:
+ (WebCore::HRTFDatabaseLoader::loadAsynchronously):
+ (WebCore::databaseLoaderEntry): Deleted.
+ * platform/audio/HRTFDatabaseLoader.h:
+ * platform/audio/ReverbConvolver.cpp:
+ (WebCore::ReverbConvolver::ReverbConvolver):
+ (WebCore::backgroundThreadEntry): Deleted.
+ * platform/audio/ReverbConvolver.h:
+ (WebCore::ReverbConvolver::useBackgroundThreads):
+ * platform/network/cf/LoaderRunLoopCF.cpp:
+ (WebCore::loaderRunLoop):
+ (WebCore::runLoaderThread): Deleted.
+ * platform/network/curl/CurlManager.cpp:
+ (WebCore::CurlManager::startThreadIfNeeded):
+ (WebCore::CurlManager::workerThread):
+ * platform/network/curl/CurlManager.h:
+ * workers/WorkerThread.cpp:
+ (WebCore::WorkerThread::start):
+ (WebCore::WorkerThread::workerThreadStart): Deleted.
+ * workers/WorkerThread.h:
+
2017-06-26 Joanmarie Diggs <[email protected]>
[ATK] Add support for aria-details and aria-errormessage
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (218815 => 218816)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -56,7 +56,9 @@
: m_backingStoreTemporaryFileHandler(fileHandler)
{
Locker<Lock> locker(m_databaseThreadCreationLock);
- m_thread = Thread::create(IDBServer::databaseThreadEntry, this, "IndexedDatabase Server");
+ m_thread = Thread::create("IndexedDatabase Server", [this] {
+ databaseRunLoop();
+ });
}
IDBServer::IDBServer(const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler)
@@ -66,7 +68,9 @@
LOG(IndexedDB, "IDBServer created at path %s", databaseDirectoryPath.utf8().data());
Locker<Lock> locker(m_databaseThreadCreationLock);
- m_thread = Thread::create(IDBServer::databaseThreadEntry, this, "IndexedDatabase Server");
+ m_thread = Thread::create("IndexedDatabase Server", [this] {
+ databaseRunLoop();
+ });
}
void IDBServer::registerConnection(IDBConnectionToClient& connection)
@@ -500,13 +504,6 @@
});
}
-void IDBServer::databaseThreadEntry(void* threadData)
-{
- ASSERT(threadData);
- IDBServer* server = reinterpret_cast<IDBServer*>(threadData);
- server->databaseRunLoop();
-}
-
void IDBServer::databaseRunLoop()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (218815 => 218816)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -118,7 +118,6 @@
void performCloseAndDeleteDatabasesForOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID);
void didPerformCloseAndDeleteDatabases(uint64_t callbackID);
- static void databaseThreadEntry(void*);
void databaseRunLoop();
void handleTaskRepliesOnMainThread();
Modified: trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp (218815 => 218816)
--- trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -39,7 +39,9 @@
{
// Start worker thread.
LockHolder lock(m_threadCreationMutex);
- m_thread = Thread::create(AsyncAudioDecoder::threadEntry, this, "Audio Decoder");
+ m_thread = Thread::create("Audio Decoder", [this] {
+ runLoop();
+ });
}
AsyncAudioDecoder::~AsyncAudioDecoder()
@@ -59,14 +61,6 @@
m_queue.append(WTFMove(decodingTask)); // note that ownership of the task is effectively taken by the queue.
}
-// Asynchronously decode in this thread.
-void AsyncAudioDecoder::threadEntry(void* threadData)
-{
- ASSERT(threadData);
- AsyncAudioDecoder* decoder = reinterpret_cast<AsyncAudioDecoder*>(threadData);
- decoder->runLoop();
-}
-
void AsyncAudioDecoder::runLoop()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h (218815 => 218816)
--- trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -74,7 +74,6 @@
RefPtr<AudioBuffer> m_audioBuffer;
};
- static void threadEntry(void* threadData);
void runLoop();
RefPtr<Thread> m_thread;
Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp (218815 => 218816)
--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -82,18 +82,12 @@
if (!m_startedRendering) {
m_startedRendering = true;
ref(); // See corresponding deref() call in notifyCompleteDispatch().
- m_renderThread = Thread::create(OfflineAudioDestinationNode::offlineRenderEntry, this, "offline renderer");
+ m_renderThread = Thread::create("offline renderer", [this] {
+ offlineRender();
+ });
}
}
-// Do offline rendering in this thread.
-void OfflineAudioDestinationNode::offlineRenderEntry(void* threadData)
-{
- OfflineAudioDestinationNode* destinationNode = reinterpret_cast<OfflineAudioDestinationNode*>(threadData);
- ASSERT(destinationNode);
- destinationNode->offlineRender();
-}
-
void OfflineAudioDestinationNode::offlineRender()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.h (218815 => 218816)
--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -65,7 +65,6 @@
// Rendering thread.
RefPtr<Thread> m_renderThread;
bool m_startedRendering;
- static void offlineRenderEntry(void* threadData);
void offlineRender();
// For completion callback on main thread.
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp (218815 => 218816)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -63,7 +63,9 @@
if (m_thread)
return true;
- m_thread = Thread::create(DatabaseThread::databaseThreadStart, this, "WebCore: Database");
+ m_thread = Thread::create("WebCore: Database", [this] {
+ databaseThread();
+ });
return m_thread;
}
@@ -87,12 +89,6 @@
return m_queue.killed();
}
-void DatabaseThread::databaseThreadStart(void* vDatabaseThread)
-{
- DatabaseThread* dbThread = static_cast<DatabaseThread*>(vDatabaseThread);
- dbThread->databaseThread();
-}
-
void DatabaseThread::databaseThread()
{
{
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h (218815 => 218816)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -65,7 +65,6 @@
private:
DatabaseThread();
- static void databaseThreadStart(void*);
void databaseThread();
Lock m_threadCreationMutex;
Modified: trunk/Source/WebCore/bindings/js/GCController.cpp (218815 => 218816)
--- trunk/Source/WebCore/bindings/js/GCController.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/bindings/js/GCController.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -38,7 +38,7 @@
namespace WebCore {
-static void collect(void*)
+static void collect()
{
JSLockHolder lock(commonVM());
commonVM().heap.collectNow(Async, CollectionScope::Full);
@@ -76,7 +76,7 @@
void GCController::gcTimerFired()
{
- collect(nullptr);
+ collect();
}
void GCController::garbageCollectNow()
@@ -101,7 +101,7 @@
void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone)
{
- RefPtr<Thread> thread = Thread::create(collect, 0, "WebCore: GCController");
+ RefPtr<Thread> thread = Thread::create("WebCore: GCController", &collect);
if (waitUntilDone) {
thread->waitForCompletion();
Modified: trunk/Source/WebCore/loader/icon/IconDatabase.cpp (218815 => 218816)
--- trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -141,7 +141,9 @@
// Lock here as well as first thing in the thread so the thread doesn't actually commence until the createThread() call
// completes and m_syncThreadRunning is properly set
m_syncLock.lock();
- m_syncThread = Thread::create(IconDatabase::iconDatabaseSyncThreadStart, this, "WebCore: IconDatabase");
+ m_syncThread = Thread::create("WebCore: IconDatabase", [this] {
+ iconDatabaseSyncThread();
+ });
m_syncThreadRunning = m_syncThread;
m_syncLock.unlock();
if (!m_syncThread)
@@ -942,13 +944,6 @@
return m_threadTerminationRequested || m_removeIconsRequested;
}
-void IconDatabase::iconDatabaseSyncThreadStart(void* vIconDatabase)
-{
- IconDatabase* iconDB = static_cast<IconDatabase*>(vIconDatabase);
-
- iconDB->iconDatabaseSyncThread();
-}
-
void IconDatabase::iconDatabaseSyncThread()
{
// The call to create this thread might not complete before the thread actually starts, so we might fail this ASSERT_ICON_SYNC_THREAD() because the pointer
Modified: trunk/Source/WebCore/loader/icon/IconDatabase.h (218815 => 218816)
--- trunk/Source/WebCore/loader/icon/IconDatabase.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -182,7 +182,6 @@
WEBCORE_EXPORT bool shouldStopThreadActivity() const final;
private:
- static void iconDatabaseSyncThreadStart(void *);
void iconDatabaseSyncThread();
// The following block of methods are called exclusively by the sync thread to manage i/o to and from the database
Modified: trunk/Source/WebCore/page/ResourceUsageThread.cpp (218815 => 218816)
--- trunk/Source/WebCore/page/ResourceUsageThread.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/page/ResourceUsageThread.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -100,14 +100,11 @@
return;
m_vm = &commonVM();
- m_thread = Thread::create(threadCallback, this, "WebCore: ResourceUsage");
+ m_thread = Thread::create("WebCore: ResourceUsage", [this] {
+ threadBody();
+ });
}
-void ResourceUsageThread::threadCallback(void* resourceUsageThread)
-{
- static_cast<ResourceUsageThread*>(resourceUsageThread)->threadBody();
-}
-
NO_RETURN void ResourceUsageThread::threadBody()
{
using namespace std::literals::chrono_literals;
Modified: trunk/Source/WebCore/page/ResourceUsageThread.h (218815 => 218816)
--- trunk/Source/WebCore/page/ResourceUsageThread.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/page/ResourceUsageThread.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -58,7 +58,6 @@
void notifyObservers(ResourceUsageData&&);
void createThreadIfNeeded();
- static void threadCallback(void* scrollingThread);
void threadBody();
void platformThreadBody(JSC::VM*, ResourceUsageData&);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp (218815 => 218816)
--- trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -80,7 +80,10 @@
{
std::unique_lock<Lock> lock(m_initializeRunLoopMutex);
- m_thread = Thread::create(threadCallback, this, "WebCore: Scrolling");
+ m_thread = Thread::create("WebCore: Scrolling", [this] {
+ WTF::Thread::setCurrentThreadIsUserInteractive();
+ initializeRunLoop();
+ });
#if PLATFORM(COCOA)
m_initializeRunLoopConditionVariable.wait(lock, [this]{ return m_threadRunLoop; });
@@ -88,17 +91,6 @@
}
}
-void ScrollingThread::threadCallback(void* scrollingThread)
-{
- WTF::Thread::setCurrentThreadIsUserInteractive();
- static_cast<ScrollingThread*>(scrollingThread)->threadBody();
-}
-
-void ScrollingThread::threadBody()
-{
- initializeRunLoop();
-}
-
void ScrollingThread::dispatchFunctionsFromScrollingThread()
{
ASSERT(isCurrentThread());
Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.h (218815 => 218816)
--- trunk/Source/WebCore/page/scrolling/ScrollingThread.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -61,8 +61,6 @@
static ScrollingThread& singleton();
void createThreadIfNeeded();
- static void threadCallback(void* scrollingThread);
- void threadBody();
void dispatchFunctionsFromScrollingThread();
void initializeRunLoop();
Modified: trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp (218815 => 218816)
--- trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -80,14 +80,6 @@
loaderMap().remove(m_databaseSampleRate);
}
-// Asynchronously load the database in this thread.
-static void databaseLoaderEntry(void* threadData)
-{
- HRTFDatabaseLoader* loader = reinterpret_cast<HRTFDatabaseLoader*>(threadData);
- ASSERT(loader);
- loader->load();
-}
-
void HRTFDatabaseLoader::load()
{
ASSERT(!isMainThread());
@@ -105,7 +97,9 @@
if (!m_hrtfDatabase.get() && !m_databaseLoaderThread) {
// Start the asynchronous database loading process.
- m_databaseLoaderThread = Thread::create(databaseLoaderEntry, this, "HRTF database loader");
+ m_databaseLoaderThread = Thread::create("HRTF database loader", [this] {
+ load();
+ });
}
}
Modified: trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.h (218815 => 218816)
--- trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/audio/HRTFDatabaseLoader.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -61,9 +61,6 @@
float databaseSampleRate() const { return m_databaseSampleRate; }
- // Called in asynchronous loading thread.
- void load();
-
private:
// Both constructor and destructor must be called from the main thread.
explicit HRTFDatabaseLoader(float sampleRate);
@@ -72,6 +69,9 @@
// This must be called from the main thread.
void loadAsynchronously();
+ // Called in asynchronous loading thread.
+ void load();
+
std::unique_ptr<HRTFDatabase> m_hrtfDatabase;
// Holding a m_threadLock is required when accessing m_databaseLoaderThread.
Modified: trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp (218815 => 218816)
--- trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -54,12 +54,6 @@
const size_t MinFFTSize = 128;
const size_t MaxRealtimeFFTSize = 2048;
-static void backgroundThreadEntry(void* threadData)
-{
- ReverbConvolver* reverbConvolver = static_cast<ReverbConvolver*>(threadData);
- reverbConvolver->backgroundThreadEntry();
-}
-
ReverbConvolver::ReverbConvolver(AudioChannel* impulseResponse, size_t renderSliceSize, size_t maxFFTSize, size_t convolverRenderPhase, bool useBackgroundThreads)
: m_impulseResponseLength(impulseResponse->length())
, m_accumulationBuffer(impulseResponse->length() + renderSliceSize)
@@ -129,8 +123,11 @@
// Start up background thread
// FIXME: would be better to up the thread priority here. It doesn't need to be real-time, but higher than the default...
- if (this->useBackgroundThreads() && m_backgroundStages.size() > 0)
- m_backgroundThread = Thread::create(WebCore::backgroundThreadEntry, this, "convolution background thread");
+ if (this->useBackgroundThreads() && m_backgroundStages.size() > 0) {
+ m_backgroundThread = Thread::create("convolution background thread", [this] {
+ backgroundThreadEntry();
+ });
+ }
}
ReverbConvolver::~ReverbConvolver()
Modified: trunk/Source/WebCore/platform/audio/ReverbConvolver.h (218815 => 218816)
--- trunk/Source/WebCore/platform/audio/ReverbConvolver.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/audio/ReverbConvolver.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -60,10 +60,11 @@
ReverbInputBuffer* inputBuffer() { return &m_inputBuffer; }
bool useBackgroundThreads() const { return m_useBackgroundThreads; }
- void backgroundThreadEntry();
size_t latencyFrames() const;
private:
+ void backgroundThreadEntry();
+
Vector<std::unique_ptr<ReverbConvolverStage>> m_stages;
Vector<std::unique_ptr<ReverbConvolverStage>> m_backgroundStages;
size_t m_impulseResponseLength;
Modified: trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp (218815 => 218816)
--- trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -48,37 +48,34 @@
{
}
-static void runLoaderThread(void*)
+CFRunLoopRef loaderRunLoop()
{
- {
- std::lock_guard<StaticLock> lock(loaderRunLoopMutex);
+ ASSERT(isMainThread());
- loaderRunLoopObject = CFRunLoopGetCurrent();
+ std::unique_lock<StaticLock> lock(loaderRunLoopMutex);
- // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
- CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
- CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
- CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
+ if (!loaderRunLoopObject) {
+ Thread::create("WebCore: CFNetwork Loader", [] {
+ {
+ std::lock_guard<StaticLock> lock(loaderRunLoopMutex);
- loaderRunLoopConditionVariable.notifyOne();
- }
+ loaderRunLoopObject = CFRunLoopGetCurrent();
- SInt32 result;
- do {
- AutodrainedPool pool;
- result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, std::numeric_limits<double>::max(), true);
- } while (result != kCFRunLoopRunStopped && result != kCFRunLoopRunFinished);
-}
+ // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
+ CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
+ CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
+ CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
-CFRunLoopRef loaderRunLoop()
-{
- ASSERT(isMainThread());
+ loaderRunLoopConditionVariable.notifyOne();
+ }
- std::unique_lock<StaticLock> lock(loaderRunLoopMutex);
+ SInt32 result;
+ do {
+ AutodrainedPool pool;
+ result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, std::numeric_limits<double>::max(), true);
+ } while (result != kCFRunLoopRunStopped && result != kCFRunLoopRunFinished);
+ });
- if (!loaderRunLoopObject) {
- Thread::create(runLoaderThread, 0, "WebCore: CFNetwork Loader");
-
loaderRunLoopConditionVariable.wait(lock, [] { return loaderRunLoopObject; });
}
Modified: trunk/Source/WebCore/platform/network/curl/CurlManager.cpp (218815 => 218816)
--- trunk/Source/WebCore/platform/network/curl/CurlManager.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/network/curl/CurlManager.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -109,7 +109,9 @@
if (m_thread)
m_thread->waitForCompletion();
setRunThread(true);
- m_thread = Thread::create(workerThread, this, "curlThread");
+ m_thread = Thread::create("curlThread", [this] {
+ workerThread();
+ });
}
}
@@ -176,16 +178,14 @@
return false;
}
-void CurlManager::workerThread(void* data)
+void CurlManager::workerThread()
{
ASSERT(!isMainThread());
- CurlManager* manager = reinterpret_cast<CurlManager*>(data);
+ while (runThread()) {
- while (manager->runThread()) {
+ updateHandleList();
- manager->updateHandleList();
-
// Retry 'select' if it was interrupted by a process signal.
int rc = 0;
do {
@@ -204,7 +204,7 @@
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
- curl_multi_fdset(manager->getMultiHandle(), &fdread, &fdwrite, &fdexcep, &maxfd);
+ curl_multi_fdset(getMultiHandle(), &fdread, &fdwrite, &fdexcep, &maxfd);
// When the 3 file descriptors are empty, winsock will return -1
// and bail out, stopping the file download. So make sure we
// have valid file descriptors before calling select.
@@ -213,10 +213,10 @@
} while (rc == -1 && errno == EINTR);
int activeCount = 0;
- while (curl_multi_perform(manager->getMultiHandle(), &activeCount) == CURLM_CALL_MULTI_PERFORM) { }
+ while (curl_multi_perform(getMultiHandle(), &activeCount) == CURLM_CALL_MULTI_PERFORM) { }
int messagesInQueue = 0;
- CURLMsg* msg = curl_multi_info_read(manager->getMultiHandle(), &messagesInQueue);
+ CURLMsg* msg = curl_multi_info_read(getMultiHandle(), &messagesInQueue);
if (!msg)
continue;
@@ -230,9 +230,9 @@
CurlJobAction action = ""
if (action == CurlJobAction::Finished)
- manager->removeFromCurl(msg->easy_handle);
+ removeFromCurl(msg->easy_handle);
- manager->stopThreadIfIdle();
+ stopThreadIfIdle();
}
}
Modified: trunk/Source/WebCore/platform/network/curl/CurlManager.h (218815 => 218816)
--- trunk/Source/WebCore/platform/network/curl/CurlManager.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/platform/network/curl/CurlManager.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -84,7 +84,7 @@
bool addToCurl(CURL* curlHandle);
bool removeFromCurl(CURL* curlHandle);
- static void workerThread(void* data);
+ void workerThread();
RefPtr<Thread> m_thread;
CURLM* m_curlMultiHandle { nullptr };
Modified: trunk/Source/WebCore/workers/WorkerThread.cpp (218815 => 218816)
--- trunk/Source/WebCore/workers/WorkerThread.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/workers/WorkerThread.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -138,16 +138,13 @@
if (m_thread)
return true;
- m_thread = Thread::create(WorkerThread::workerThreadStart, this, "WebCore: Worker");
+ m_thread = Thread::create("WebCore: Worker", [this] {
+ workerThread();
+ });
return m_thread;
}
-void WorkerThread::workerThreadStart(void* thread)
-{
- static_cast<WorkerThread*>(thread)->workerThread();
-}
-
void WorkerThread::workerThread()
{
// Propagate the mainThread's fenv to workers.
Modified: trunk/Source/WebCore/workers/WorkerThread.h (218815 => 218816)
--- trunk/Source/WebCore/workers/WorkerThread.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebCore/workers/WorkerThread.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -94,8 +94,6 @@
SocketProvider* socketProvider();
private:
- // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
- static void workerThreadStart(void*);
void workerThread();
RefPtr<Thread> m_thread;
Modified: trunk/Source/WebKit/ChangeLog (218815 => 218816)
--- trunk/Source/WebKit/ChangeLog 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebKit/ChangeLog 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1,3 +1,15 @@
+2017-06-26 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread::create(obsolete things) API since we can use lambda
+ https://bugs.webkit.org/show_bug.cgi?id=173825
+
+ Reviewed by Saam Barati.
+
+ * Storage/StorageThread.cpp:
+ (WebCore::StorageThread::start):
+ (WebCore::StorageThread::threadEntryPointCallback): Deleted.
+ * Storage/StorageThread.h:
+
2017-06-16 Alex Christensen <[email protected]>
Fix Visual Studio 2017 64-bit build after r218258
Modified: trunk/Source/WebKit/Storage/StorageThread.cpp (218815 => 218816)
--- trunk/Source/WebKit/Storage/StorageThread.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebKit/Storage/StorageThread.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -53,17 +53,15 @@
bool StorageThread::start()
{
ASSERT(isMainThread());
- if (!m_thread)
- m_thread = Thread::create(StorageThread::threadEntryPointCallback, this, "WebCore: LocalStorage");
+ if (!m_thread) {
+ m_thread = Thread::create("WebCore: LocalStorage", [this] {
+ threadEntryPoint();
+ });
+ }
activeStorageThreads().add(this);
return m_thread;
}
-void StorageThread::threadEntryPointCallback(void* thread)
-{
- static_cast<StorageThread*>(thread)->threadEntryPoint();
-}
-
void StorageThread::threadEntryPoint()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebKit/Storage/StorageThread.h (218815 => 218816)
--- trunk/Source/WebKit/Storage/StorageThread.h 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Source/WebKit/Storage/StorageThread.h 2017-06-26 18:19:36 UTC (rev 218816)
@@ -49,8 +49,6 @@
static void releaseFastMallocFreeMemoryInAllThreads();
private:
- // Called on background thread.
- static void threadEntryPointCallback(void*);
void threadEntryPoint();
// Background thread part of the terminate procedure.
Modified: trunk/Tools/ChangeLog (218815 => 218816)
--- trunk/Tools/ChangeLog 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Tools/ChangeLog 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1,3 +1,18 @@
+2017-06-26 Yusuke Suzuki <[email protected]>
+
+ [WTF] Drop Thread::create(obsolete things) API since we can use lambda
+ https://bugs.webkit.org/show_bug.cgi?id=173825
+
+ Reviewed by Saam Barati.
+
+ * DumpRenderTree/_javascript_Threading.cpp:
+ (runJavaScriptThread):
+ (startJavaScriptThreads):
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (runThread):
+ (runPthread):
+ (testThreadIdentifierMap):
+
2017-06-26 David Kilzer <[email protected]>
[TestWebKitAPI] Fix false-positive bad release warnings found by clang static analyzer
Modified: trunk/Tools/DumpRenderTree/_javascript_Threading.cpp (218815 => 218816)
--- trunk/Tools/DumpRenderTree/_javascript_Threading.cpp 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Tools/DumpRenderTree/_javascript_Threading.cpp 2017-06-26 18:19:36 UTC (rev 218816)
@@ -61,7 +61,7 @@
// This function exercises JSC in a loop until _javascript_ThreadsShouldTerminate
// becomes true or it probabilistically decides to spawn a replacement thread and exit.
-void runJavaScriptThread(void*)
+void runJavaScriptThread()
{
static const char* const script =
"var array = [];"
@@ -111,7 +111,7 @@
Thread& thread = Thread::current();
thread.detach();
_javascript_Threads().remove(&thread);
- _javascript_Threads().add(Thread::create(&runJavaScriptThread, 0, 0));
+ _javascript_Threads().add(Thread::create("_javascript_ Thread", &runJavaScriptThread));
break;
}
@@ -128,7 +128,7 @@
LockHolder locker(_javascript_ThreadsMutex());
for (size_t i = 0; i < _javascript_ThreadsCount; ++i)
- _javascript_Threads().add(Thread::create(&runJavaScriptThread, 0, 0));
+ _javascript_Threads().add(Thread::create("_javascript_ Thread", &runJavaScriptThread));
}
void stopJavaScriptThreads()
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (218815 => 218816)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2017-06-26 18:02:39 UTC (rev 218815)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2017-06-26 18:19:36 UTC (rev 218816)
@@ -1052,7 +1052,7 @@
[[NSUserDefaults standardUserDefaults] setVolatileDomain:processInstanceDefaults forName:NSArgumentDomain];
}
-static void runThread(void* arg)
+static void runThread()
{
static ThreadIdentifier previousId = 0;
ThreadIdentifier currentId = currentThread();
@@ -1061,10 +1061,10 @@
previousId = currentId;
}
-static void* runPthread(void* arg)
+static void* runPthread(void*)
{
- runThread(arg);
- return 0;
+ runThread();
+ return nullptr;
}
static void testThreadIdentifierMap()
@@ -1079,7 +1079,7 @@
// Now create another thread using WTF. On OSX, it will have the same pthread handle
// but should get a different RefPtr<Thread>.
- Thread::create(runThread, 0, "DumpRenderTree: test");
+ Thread::create("DumpRenderTree: test", runThread);
}
static void allocateGlobalControllers()