Changeset 142163 in webkit


Ignore:
Timestamp:
Feb 7, 2013 12:35:09 PM (4 years ago)
Author:
benjamin@webkit.org
Message:

Upstream iOS isWebThread() and isUIThread()
https://bugs.webkit.org/show_bug.cgi?id=109130

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-02-07
Reviewed by Sam Weinig.

Source/WebCore:

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject initialize]):

  • platform/mac/SharedBufferMac.mm:

(+[WebCoreSharedBufferData initialize]):
#ifdef out the legacy initialization as it is not correct when
using a WebThread.

Source/WTF:

On iOS, it is sometimes necessary to differenciate the thread running WebCore,
and the thread running the UI. This patch upstream those functions.

  • wtf/MainThread.cpp:
  • wtf/MainThread.h:

Disable the legacy initializer as it is incorrect when using the WebThread to run WebCore.
(WTF::isWebThread):
(WTF::isUIThread):
Return true when the current thread is the Web/UI thread.

  • wtf/mac/MainThreadMac.mm:

(WTF::isUIThread):
(WTF::isWebThread):

  • wtf/text/AtomicString.cpp:

(WTF::AtomicStringTable::create):
Use the newly added methods.

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r142129 r142163  
     12013-02-07  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Upstream iOS isWebThread() and isUIThread()
     4        https://bugs.webkit.org/show_bug.cgi?id=109130
     5
     6        Reviewed by Sam Weinig.
     7
     8        On iOS, it is sometimes necessary to differenciate the thread running WebCore,
     9        and the thread running the UI. This patch upstream those functions.
     10
     11        * wtf/MainThread.cpp:
     12        * wtf/MainThread.h:
     13        Disable the legacy initializer as it is incorrect when using the WebThread to run WebCore.
     14        (WTF::isWebThread):
     15        (WTF::isUIThread):
     16        Return true when the current thread is the Web/UI thread.
     17
     18        * wtf/mac/MainThreadMac.mm:
     19        (WTF::isUIThread):
     20        (WTF::isWebThread):
     21
     22        * wtf/text/AtomicString.cpp:
     23        (WTF::AtomicStringTable::create):
     24        Use the newly added methods.
     25
    1262013-02-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    227
  • trunk/Source/WTF/wtf/MainThread.cpp

    r111778 r142163  
    121121}
    122122
     123#if !USE(WEB_THREAD)
    123124static void initializeMainThreadToProcessMainThreadOnce()
    124125{
     
    131132    pthread_once(&initializeMainThreadKeyOnce, initializeMainThreadToProcessMainThreadOnce);
    132133}
     134#endif // !USE(WEB_THREAD)
     135
    133136#endif
    134137
  • trunk/Source/WTF/wtf/MainThread.h

    r131496 r142163  
    5252WTF_EXPORT_PRIVATE bool isMainThread();
    5353
     54#if USE(WEB_THREAD)
     55WTF_EXPORT_PRIVATE bool isWebThread();
     56WTF_EXPORT_PRIVATE bool isUIThread();
     57#else
     58inline bool isWebThread() { return isMainThread(); }
     59inline bool isUIThread() { return isMainThread(); }
     60#endif // PLATFORM(IOS)
     61
     62
    5463void initializeGCThreads();
    5564
     
    6978
    7079#if PLATFORM(MAC)
     80#if !USE(WEB_THREAD)
    7181// This version of initializeMainThread sets up the main thread as corresponding
    7282// to the process's main thread, and not necessarily the thread that calls this
    7383// function. It should only be used as a legacy aid for Mac WebKit.
    7484WTF_EXPORT_PRIVATE void initializeMainThreadToProcessMainThread();
     85#endif // !USE(WEB_THREAD)
    7586void initializeMainThreadToProcessMainThreadPlatform();
    7687#endif
  • trunk/Source/WTF/wtf/mac/MainThreadMac.mm

    r111778 r142163  
    7171}
    7272
     73#if !USE(WEB_THREAD)
    7374void initializeMainThreadToProcessMainThreadPlatform()
    7475{
     
    8586    initializeGCThreads();
    8687}
     88#endif // !USE(WEB_THREAD)
    8789
    8890static void timerFired(CFRunLoopTimerRef timer, void*)
     
    134136}
    135137
     138#if USE(WEB_THREAD)
     139bool isUIThread()
     140{
     141    return pthread_main_np();
     142}
     143
     144bool isWebThread()
     145{
     146    return pthread_equal(pthread_self(), mainThreadPthread);
     147}
     148#endif // USE(WEB_THREAD)
     149
    136150} // namespace WTF
  • trunk/Source/WTF/wtf/text/AtomicString.cpp

    r141819 r142163  
    7575
    7676        bool currentThreadIsWebThread = isWebThread();
    77         if (currentThreadIsWebThread || pthread_main_np())
     77        if (currentThreadIsWebThread || isUIThread())
    7878            data.m_atomicStringTable = sharedStringTable;
    7979        else
  • trunk/Source/WebCore/ChangeLog

    r142161 r142163  
     12013-02-07  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Upstream iOS isWebThread() and isUIThread()
     4        https://bugs.webkit.org/show_bug.cgi?id=109130
     5
     6        Reviewed by Sam Weinig.
     7
     8        * bindings/objc/WebScriptObject.mm:
     9        (+[WebScriptObject initialize]):
     10        * platform/mac/SharedBufferMac.mm:
     11        (+[WebCoreSharedBufferData initialize]):
     12        #ifdef out the legacy initialization as it is not correct when
     13        using a WebThread.
     14
    1152013-02-07  Vivek Galatage  <vivek.vg@samsung.com>
    216
  • trunk/Source/WebCore/bindings/objc/WebScriptObject.mm

    r136986 r142163  
    128128+ (void)initialize
    129129{
     130#if !USE(WEB_THREAD)
    130131    JSC::initializeThreading();
    131132    WTF::initializeMainThreadToProcessMainThread();
     133#endif // !USE(WEB_THREAD)
    132134    WebCoreObjCFinalizeOnMainThread(self);
    133135}
  • trunk/Source/WebCore/platform/mac/SharedBufferMac.mm

    r99239 r142163  
    4848+ (void)initialize
    4949{
     50#if !USE(WEB_THREAD)
    5051    JSC::initializeThreading();
    5152#if PLATFORM(QT) && USE(QTKIT)
     
    5455    WTF::initializeMainThreadToProcessMainThread();
    5556#endif
     57#endif // !USE(WEB_THREAD)
    5658    WebCoreObjCFinalizeOnMainThread(self);
    5759}
Note: See TracChangeset for help on using the changeset viewer.