Changeset 57732 in webkit


Ignore:
Timestamp:
Apr 16, 2010 12:36:08 PM (14 years ago)
Author:
andersca@apple.com
Message:

2010-04-16 Anders Carlsson <andersca@apple.com>

Reviewed by David Hyatt.

Make run loops be allocated as thread specific data.
https://bugs.webkit.org/show_bug.cgi?id=37723

  • Platform/RunLoop.cpp: (RunLoop::initializeMainRunLoop): (RunLoop::current): (RunLoop::main):
  • Platform/RunLoop.h:
  • Platform/mac/RunLoopMac.mm: (RunLoop::run): (RunLoop::stop):
  • UIProcess/Launcher/mac/WebProcessLauncher.mm: (WebKit::webThreadBody): (WebKit::launchWebProcess):
  • UIProcess/ResponsivenessTimer.cpp: (WebKit::ResponsivenessTimer::ResponsivenessTimer):
  • WebProcess/Launching/mac/WebProcessMain.mm: (main):
  • WebProcess/WebProcess.cpp: (WebKit::WebProcess::isSeparateProcess):
Location:
trunk/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r57707 r57732  
     12010-04-16  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        Make run loops be allocated as thread specific data.
     6        https://bugs.webkit.org/show_bug.cgi?id=37723
     7
     8        * Platform/RunLoop.cpp:
     9        (RunLoop::initializeMainRunLoop):
     10        (RunLoop::current):
     11        (RunLoop::main):
     12        * Platform/RunLoop.h:
     13        * Platform/mac/RunLoopMac.mm:
     14        (RunLoop::run):
     15        (RunLoop::stop):
     16        * UIProcess/Launcher/mac/WebProcessLauncher.mm:
     17        (WebKit::webThreadBody):
     18        (WebKit::launchWebProcess):
     19        * UIProcess/ResponsivenessTimer.cpp:
     20        (WebKit::ResponsivenessTimer::ResponsivenessTimer):
     21        * WebProcess/Launching/mac/WebProcessMain.mm:
     22        (main):
     23        * WebProcess/WebProcess.cpp:
     24        (WebKit::WebProcess::isSeparateProcess):
     25
    1262010-04-16  Sam Weinig  <weinig@apple.com>
    227
  • trunk/WebKit2/Platform/RunLoop.cpp

    r57454 r57732  
    2727
    2828#include "WorkItem.h"
     29#include <wtf/StdLibExtras.h>
    2930
    3031static RunLoop* s_mainRunLoop;
     
    3435    if (s_mainRunLoop)
    3536        return;
    36     s_mainRunLoop = new RunLoop;
     37    s_mainRunLoop = RunLoop::current();
    3738}
    3839
    39 RunLoop* RunLoop::mainRunLoop()
     40RunLoop* RunLoop::current()
     41{
     42    DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop>, runLoopData, ());
     43    return &*runLoopData;
     44}
     45
     46RunLoop* RunLoop::main()
    4047{
    4148    ASSERT(s_mainRunLoop);
  • trunk/WebKit2/Platform/RunLoop.h

    r57454 r57732  
    2929#include <memory>
    3030#include <wtf/HashMap.h>
     31#include <wtf/ThreadSpecific.h>
    3132#include <wtf/Threading.h>
    3233#include <wtf/Vector.h>
     
    3839    // Must be called from the main thread.
    3940    static void initializeMainRunLoop();
    40     static RunLoop* mainRunLoop();
    4141
    42     RunLoop();
    43     ~RunLoop();
     42    static RunLoop* current();
     43    static RunLoop* main();
    4444
    4545    void scheduleWork(std::auto_ptr<WorkItem>);
    4646   
    47     void run();
     47    static void run();
    4848    void stop();
    4949
     
    9696
    9797private:
     98    friend class WTF::ThreadSpecific<RunLoop>;
     99
     100    RunLoop();
     101    ~RunLoop();
     102   
    98103    void performWork();
    99104    void wakeUp();
  • trunk/WebKit2/Platform/mac/RunLoopMac.mm

    r57547 r57732  
    5151void RunLoop::run()
    5252{
    53     ASSERT(m_runLoop == CFRunLoopGetCurrent());
    54    
    55     if (m_runLoop == mainRunLoop()->m_runLoop) {
     53    if (current() == main()) {
    5654        // Use -[NSApplication run] for the main run loop.
    5755        [NSApp run];
     
    6664    ASSERT(m_runLoop == CFRunLoopGetCurrent());
    6765   
    68     if (m_runLoop == mainRunLoop()->m_runLoop) {
     66    if (m_runLoop == main()->m_runLoop) {
    6967        [NSApp stop:nil];
    7068        NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
  • trunk/WebKit2/UIProcess/Launcher/mac/WebProcessLauncher.mm

    r57310 r57732  
    5050    JSC::initializeThreading();
    5151
    52     RunLoop runLoop;
    53     WebProcess::shared().initialize(serverPort, &runLoop);
     52    WebProcess::shared().initialize(serverPort, RunLoop::current());
    5453
    5554    [pool drain];
    5655
    57     runLoop.run();
     56    RunLoop::current()->run();
    5857
    5958    return 0;
     
    7170    mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
    7271
    73     info.connection = CoreIPC::Connection::createServerConnection(listeningPort, client, RunLoop::mainRunLoop());
     72    info.connection = CoreIPC::Connection::createServerConnection(listeningPort, client, RunLoop::main());
    7473    info.connection->open();
    7574
  • trunk/WebKit2/UIProcess/ResponsivenessTimer.cpp

    r57359 r57732  
    3535    : m_client(client)
    3636    , m_isResponsive(true)
    37     , m_timer(RunLoop::mainRunLoop(), this, &ResponsivenessTimer::timerFired)
     37    , m_timer(RunLoop::main(), this, &ResponsivenessTimer::timerFired)
    3838{
    3939}
  • trunk/WebKit2/WebProcess/Launching/mac/WebProcessMain.mm

    r57309 r57732  
    6363   
    6464    // Create the connection.
    65     WebProcess::shared().initialize(serverPort, RunLoop::mainRunLoop());
     65    WebProcess::shared().initialize(serverPort, RunLoop::main());
    6666   
    6767    [pool drain];
     
    7070    [NSApplication sharedApplication];
    7171
    72     RunLoop::mainRunLoop()->run();
     72    RunLoop::run();
    7373
    7474    // FIXME: Do more cleanup here.
  • trunk/WebKit2/WebProcess/WebProcess.cpp

    r57549 r57732  
    8888{
    8989    // If we're running on the main run loop, we assume that we're in a separate process.
    90     return m_runLoop == RunLoop::mainRunLoop();
     90    return m_runLoop == RunLoop::main();
    9191}
    9292 
Note: See TracChangeset for help on using the changeset viewer.