Title: [218012] trunk/Source
- Revision
- 218012
- Author
- [email protected]
- Date
- 2017-06-09 12:41:13 -0700 (Fri, 09 Jun 2017)
Log Message
Update Thread::create() to take in a WTF::Function instead of a std::function
https://bugs.webkit.org/show_bug.cgi?id=173175
Reviewed by Mark Lam.
Source/_javascript_Core:
* API/tests/CompareAndSwapTest.cpp:
(testCompareAndSwap):
Source/WTF:
Update Thread::create() to take in a WTF::Function instead of a std::function. Unlike
std::function, WTF:Function is not copyable and does not make implicit copies of captured
variables. Doing captures such as [string = string.isolatedCopy()] when passing an
std::function to another thread has lead to bugs in the past due to implicit copying of
the captured string.
* wtf/Threading.cpp:
(WTF::Thread::create):
* wtf/Threading.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/tests/CompareAndSwapTest.cpp (218011 => 218012)
--- trunk/Source/_javascript_Core/API/tests/CompareAndSwapTest.cpp 2017-06-09 19:40:36 UTC (rev 218011)
+++ trunk/Source/_javascript_Core/API/tests/CompareAndSwapTest.cpp 2017-06-09 19:41:13 UTC (rev 218012)
@@ -106,8 +106,7 @@
data[i].bitmap = &bitmap;
data[i].id = i;
data[i].numThreads = numThreads;
- std::function<void()> threadFunc = std::bind(setBitThreadFunc, &data[i]);
- threads[i] = Thread::create("setBitThreadFunc", threadFunc);
+ threads[i] = Thread::create("setBitThreadFunc", std::bind(setBitThreadFunc, &data[i]));
}
printf("Waiting for %d threads to join\n", numThreads);
Modified: trunk/Source/_javascript_Core/ChangeLog (218011 => 218012)
--- trunk/Source/_javascript_Core/ChangeLog 2017-06-09 19:40:36 UTC (rev 218011)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-06-09 19:41:13 UTC (rev 218012)
@@ -1,3 +1,13 @@
+2017-06-09 Chris Dumez <[email protected]>
+
+ Update Thread::create() to take in a WTF::Function instead of a std::function
+ https://bugs.webkit.org/show_bug.cgi?id=173175
+
+ Reviewed by Mark Lam.
+
+ * API/tests/CompareAndSwapTest.cpp:
+ (testCompareAndSwap):
+
2017-06-09 Yusuke Suzuki <[email protected]>
[DFG] Add verboseDFGOSRExit
Modified: trunk/Source/WTF/ChangeLog (218011 => 218012)
--- trunk/Source/WTF/ChangeLog 2017-06-09 19:40:36 UTC (rev 218011)
+++ trunk/Source/WTF/ChangeLog 2017-06-09 19:41:13 UTC (rev 218012)
@@ -1,5 +1,22 @@
2017-06-09 Chris Dumez <[email protected]>
+ Update Thread::create() to take in a WTF::Function instead of a std::function
+ https://bugs.webkit.org/show_bug.cgi?id=173175
+
+ Reviewed by Mark Lam.
+
+ Update Thread::create() to take in a WTF::Function instead of a std::function. Unlike
+ std::function, WTF:Function is not copyable and does not make implicit copies of captured
+ variables. Doing captures such as [string = string.isolatedCopy()] when passing an
+ std::function to another thread has lead to bugs in the past due to implicit copying of
+ the captured string.
+
+ * wtf/Threading.cpp:
+ (WTF::Thread::create):
+ * wtf/Threading.h:
+
+2017-06-09 Chris Dumez <[email protected]>
+
Update WorkQueue::concurrentApply() to take a WTF::Function instead of an std::function
https://bugs.webkit.org/show_bug.cgi?id=173165
Modified: trunk/Source/WTF/wtf/Threading.cpp (218011 => 218012)
--- trunk/Source/WTF/wtf/Threading.cpp 2017-06-09 19:40:36 UTC (rev 218011)
+++ trunk/Source/WTF/wtf/Threading.cpp 2017-06-09 19:41:13 UTC (rev 218012)
@@ -48,7 +48,7 @@
WTF_MAKE_FAST_ALLOCATED;
public:
const char* name;
- std::function<void()> entryPoint;
+ Function<void()> entryPoint;
Mutex creationMutex;
};
@@ -99,7 +99,7 @@
entryPoint();
}
-RefPtr<Thread> Thread::create(const char* name, std::function<void()> entryPoint)
+RefPtr<Thread> Thread::create(const char* name, Function<void()>&& entryPoint)
{
NewThreadContext* context = new NewThreadContext { name, WTFMove(entryPoint), { } };
Modified: trunk/Source/WTF/wtf/Threading.h (218011 => 218012)
--- trunk/Source/WTF/wtf/Threading.h 2017-06-09 19:40:36 UTC (rev 218011)
+++ trunk/Source/WTF/wtf/Threading.h 2017-06-09 19:41:13 UTC (rev 218012)
@@ -41,6 +41,7 @@
#include <wtf/Assertions.h>
#include <wtf/Atomics.h>
#include <wtf/Expected.h>
+#include <wtf/Function.h>
#include <wtf/Locker.h>
#include <wtf/LocklessBag.h>
#include <wtf/Noncopyable.h>
@@ -73,7 +74,7 @@
// Returns nullptr if thread creation failed.
// The thread name must be a literal since on some platforms it's passed in to the thread.
- WTF_EXPORT_PRIVATE static RefPtr<Thread> create(const char* threadName, std::function<void()>);
+ WTF_EXPORT_PRIVATE static RefPtr<Thread> create(const char* threadName, Function<void()>&&);
WTF_EXPORT_PRIVATE static RefPtr<Thread> create(ThreadFunction entryPoint, void* data, const char* name);
// Returns Thread object.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes