[WTF] Drop Thread::create(obsolete things) API since we can use lambda
[WebKit-https.git] / Source / WTF / wtf / ParallelJobsGeneric.cpp
index cce1106..aacc7cc 100644 (file)
@@ -93,8 +93,22 @@ bool ParallelEnvironment::ThreadPrivate::tryLockFor(ParallelEnvironment* parent)
         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 @@ void ParallelEnvironment::ThreadPrivate::waitForFinish()
         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)