Title: [225205] trunk/Source
- Revision
- 225205
- Author
- cdu...@apple.com
- Date
- 2017-11-27 16:46:47 -0800 (Mon, 27 Nov 2017)
Log Message
Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h
https://bugs.webkit.org/show_bug.cgi?id=180060
Reviewed by Alex Christensen.
Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h so that it can be reused.
Source/WebCore:
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::callOnMainThreadAndWait): Deleted.
Source/WTF:
* wtf/MainThread.cpp:
(WTF::callOnMainThreadAndWait):
* wtf/MainThread.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (225204 => 225205)
--- trunk/Source/WTF/ChangeLog 2017-11-28 00:22:52 UTC (rev 225204)
+++ trunk/Source/WTF/ChangeLog 2017-11-28 00:46:47 UTC (rev 225205)
@@ -1,3 +1,16 @@
+2017-11-27 Chris Dumez <cdu...@apple.com>
+
+ Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h
+ https://bugs.webkit.org/show_bug.cgi?id=180060
+
+ Reviewed by Alex Christensen.
+
+ Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h so that it can be reused.
+
+ * wtf/MainThread.cpp:
+ (WTF::callOnMainThreadAndWait):
+ * wtf/MainThread.h:
+
2017-11-27 Simon Fraser <simon.fra...@apple.com>
Use TextStream's indent tracking, rather than passing indent to all the externalRepresentation() functions
Modified: trunk/Source/WTF/wtf/MainThread.cpp (225204 => 225205)
--- trunk/Source/WTF/wtf/MainThread.cpp 2017-11-28 00:22:52 UTC (rev 225204)
+++ trunk/Source/WTF/wtf/MainThread.cpp 2017-11-28 00:46:47 UTC (rev 225205)
@@ -35,6 +35,7 @@
#include "StdLibExtras.h"
#include "Threading.h"
#include <mutex>
+#include <wtf/Condition.h>
#include <wtf/Lock.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/ThreadSpecific.h>
@@ -211,4 +212,30 @@
return **isGCThread;
}
+void callOnMainThreadAndWait(WTF::Function<void()>&& function)
+{
+ if (isMainThread()) {
+ function();
+ return;
+ }
+
+ Lock mutex;
+ Condition conditionVariable;
+
+ bool isFinished = false;
+
+ callOnMainThread([&, function = WTFMove(function)] {
+ function();
+
+ std::lock_guard<Lock> lock(mutex);
+ isFinished = true;
+ conditionVariable.notifyOne();
+ });
+
+ std::unique_lock<Lock> lock(mutex);
+ conditionVariable.wait(lock, [&] {
+ return isFinished;
+ });
+}
+
} // namespace WTF
Modified: trunk/Source/WTF/wtf/MainThread.h (225204 => 225205)
--- trunk/Source/WTF/wtf/MainThread.h 2017-11-28 00:22:52 UTC (rev 225204)
+++ trunk/Source/WTF/wtf/MainThread.h 2017-11-28 00:46:47 UTC (rev 225205)
@@ -44,6 +44,7 @@
WTF_EXPORT_PRIVATE void initializeMainThread();
WTF_EXPORT_PRIVATE void callOnMainThread(Function<void()>&&);
+WTF_EXPORT_PRIVATE void callOnMainThreadAndWait(Function<void()>&&);
#if PLATFORM(COCOA)
WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());
@@ -99,6 +100,7 @@
using WTF::GCThreadType;
using WTF::callOnMainThread;
+using WTF::callOnMainThreadAndWait;
using WTF::canAccessThreadLocalDataForThread;
using WTF::isMainThread;
using WTF::isMainThreadOrGCThread;
Modified: trunk/Source/WebCore/ChangeLog (225204 => 225205)
--- trunk/Source/WebCore/ChangeLog 2017-11-28 00:22:52 UTC (rev 225204)
+++ trunk/Source/WebCore/ChangeLog 2017-11-28 00:46:47 UTC (rev 225205)
@@ -1,3 +1,15 @@
+2017-11-27 Chris Dumez <cdu...@apple.com>
+
+ Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h
+ https://bugs.webkit.org/show_bug.cgi?id=180060
+
+ Reviewed by Alex Christensen.
+
+ Move callOnMainThreadAndWait() from SocketStreamHandleImplCFNet.cpp to MainThread.h so that it can be reused.
+
+ * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+ (WebCore::callOnMainThreadAndWait): Deleted.
+
2017-11-27 Matt Lewis <jlew...@apple.com>
Unreviewed, rolling out r225201.
Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (225204 => 225205)
--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-11-28 00:22:52 UTC (rev 225204)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-11-28 00:46:47 UTC (rev 225205)
@@ -151,32 +151,6 @@
return CFSTR("WebSocket proxy PAC file execution");
}
-static void callOnMainThreadAndWait(WTF::Function<void()>&& function)
-{
- if (isMainThread()) {
- function();
- return;
- }
-
- Lock mutex;
- Condition conditionVariable;
-
- bool isFinished = false;
-
- callOnMainThread([&, function = WTFMove(function)] {
- function();
-
- std::lock_guard<Lock> lock(mutex);
- isFinished = true;
- conditionVariable.notifyOne();
- });
-
- std::unique_lock<Lock> lock(mutex);
- conditionVariable.wait(lock, [&] {
- return isFinished;
- });
-}
-
struct MainThreadPACCallbackInfo {
MainThreadPACCallbackInfo(SocketStreamHandle* handle, CFArrayRef proxyList)
: handle(handle), proxyList(proxyList)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes