Diff
Modified: trunk/Source/WTF/ChangeLog (153949 => 153950)
--- trunk/Source/WTF/ChangeLog 2013-08-12 17:32:37 UTC (rev 153949)
+++ trunk/Source/WTF/ChangeLog 2013-08-12 17:47:57 UTC (rev 153950)
@@ -1,3 +1,18 @@
+2013-08-12 Joseph Pecoraro <[email protected]>
+
+ [iOS] isMainThread implementation with USE(WEB_THREAD)
+ https://bugs.webkit.org/show_bug.cgi?id=119644
+
+ Reviewed by Benjamin Poulain.
+
+ On iOS isMainThread() means that the current thread is either the
+ MainThread or WebThread and the current thread has the WebThreadLock.
+
+ * wtf/ios/WebCoreThread.cpp: Added.
+ * wtf/ios/WebCoreThread.h: Added.
+ * wtf/mac/MainThreadMac.mm:
+ (WTF::isMainThread):
+
2013-08-11 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix make distcheck.
Added: trunk/Source/WTF/wtf/ios/WebCoreThread.cpp (0 => 153950)
--- trunk/Source/WTF/wtf/ios/WebCoreThread.cpp (rev 0)
+++ trunk/Source/WTF/wtf/ios/WebCoreThread.cpp 2013-08-12 17:47:57 UTC (rev 153950)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "WebCoreThread.h"
+
+WTF_EXPORT_PRIVATE bool (*WebCoreWebThreadIsLockedOrDisabled)(void);
Added: trunk/Source/WTF/wtf/ios/WebCoreThread.h (0 => 153950)
--- trunk/Source/WTF/wtf/ios/WebCoreThread.h (rev 0)
+++ trunk/Source/WTF/wtf/ios/WebCoreThread.h 2013-08-12 17:47:57 UTC (rev 153950)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Since this is a shared header, with the same file name as a file in
+// WebCore we prefix this with _javascript_Core to make it unique.
+#ifndef _javascript_Core_WebCoreThread_h
+#define _javascript_Core_WebCoreThread_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bool (*WebCoreWebThreadIsLockedOrDisabled)(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: trunk/Source/WTF/wtf/mac/MainThreadMac.mm (153949 => 153950)
--- trunk/Source/WTF/wtf/mac/MainThreadMac.mm 2013-08-12 17:32:37 UTC (rev 153949)
+++ trunk/Source/WTF/wtf/mac/MainThreadMac.mm 2013-08-12 17:47:57 UTC (rev 153950)
@@ -36,6 +36,10 @@
#import <wtf/HashSet.h>
#import <wtf/Threading.h>
+#if USE(WEB_THREAD)
+#include <wtf/ios/WebCoreThread.h>
+#endif
+
@interface JSWTFMainThreadCaller : NSObject {
}
- (void)call;
@@ -124,18 +128,13 @@
[staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO];
}
+#if USE(WEB_THREAD)
bool isMainThread()
{
- if (mainThreadEstablishedAsPthreadMain) {
- ASSERT(!mainThreadPthread);
- return pthread_main_np();
- }
-
- ASSERT(mainThreadPthread);
- return pthread_equal(pthread_self(), mainThreadPthread);
+ ASSERT(!mainThreadEstablishedAsPthreadMain);
+ return (isWebThread() || pthread_main_np()) && WebCoreWebThreadIsLockedOrDisabled();
}
-#if USE(WEB_THREAD)
bool isUIThread()
{
return pthread_main_np();
@@ -145,6 +144,17 @@
{
return pthread_equal(pthread_self(), mainThreadPthread);
}
+#else
+bool isMainThread()
+{
+ if (mainThreadEstablishedAsPthreadMain) {
+ ASSERT(!mainThreadPthread);
+ return pthread_main_np();
+ }
+
+ ASSERT(mainThreadPthread);
+ return pthread_equal(pthread_self(), mainThreadPthread);
+}
#endif // USE(WEB_THREAD)
} // namespace WTF