Changeset 149415 in webkit


Ignore:
Timestamp:
Apr 30, 2013, 5:02:12 PM (12 years ago)
Author:
andersca@apple.com
Message:

Make RunLoop ref-counted
https://bugs.webkit.org/show_bug.cgi?id=115384

Reviewed by Benjamin Poulain.

Add a RunLoop::Holder class which creates and holds the ref-counted RunLoop object.

  • platform/RunLoop.cpp:

(RunLoop::Holder):
(WebCore::RunLoop::Holder::Holder):
(WebCore::RunLoop::Holder::runLoop):
(WebCore::RunLoop::current):

  • platform/RunLoop.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149410 r149415  
     12013-04-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Make RunLoop ref-counted
     4        https://bugs.webkit.org/show_bug.cgi?id=115384
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Add a RunLoop::Holder class which creates and holds the ref-counted RunLoop object.
     9
     10        * platform/RunLoop.cpp:
     11        (RunLoop::Holder):
     12        (WebCore::RunLoop::Holder::Holder):
     13        (WebCore::RunLoop::Holder::runLoop):
     14        (WebCore::RunLoop::current):
     15        * platform/RunLoop.h:
     16
    1172013-04-30  Anders Carlsson  <andersca@apple.com>
    218
  • trunk/Source/WebCore/platform/RunLoop.cpp

    r149410 r149415  
    2828
    2929#include <wtf/StdLibExtras.h>
     30#include <wtf/ThreadSpecific.h>
    3031
    3132namespace WebCore {
     
    3940static RunLoop* s_mainRunLoop;
    4041
     42// Helper class for ThreadSpecificData.
     43class RunLoop::Holder {
     44public:
     45    Holder()
     46        : m_runLoop(adoptRef(new RunLoop))
     47    {
     48    }
     49
     50    RunLoop* runLoop() const { return m_runLoop.get(); }
     51
     52private:
     53    RefPtr<RunLoop> m_runLoop;
     54};
     55
    4156void RunLoop::initializeMainRunLoop()
    4257{
     
    4863RunLoop* RunLoop::current()
    4964{
    50     DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop>, runLoopData, ());
    51     return &*runLoopData;
     65    DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop::Holder>, runLoopHolder, ());
     66    return runLoopHolder->runLoop();
    5267}
    5368
  • trunk/Source/WebCore/platform/RunLoop.h

    r149410 r149415  
    3434#include <wtf/HashMap.h>
    3535#include <wtf/RetainPtr.h>
    36 #include <wtf/ThreadSpecific.h>
    3736#include <wtf/Threading.h>
    3837
     
    4746namespace WebCore {
    4847
    49 class RunLoop {
     48class RunLoop : public ThreadSafeRefCounted<RunLoop> {
    5049public:
    5150    // Must be called from the main thread (except for the Mac platform, where it
     
    5857    static RunLoop* current();
    5958    static RunLoop* main();
     59    ~RunLoop();
    6060
    6161    void dispatch(const Function<void()>&);
     
    131131    };
    132132
     133    class Holder;
     134
    133135private:
    134     friend class WTF::ThreadSpecific<RunLoop>;
    135 
    136136    RunLoop();
    137     ~RunLoop();
    138137
    139138    void performWork();
Note: See TracChangeset for help on using the changeset viewer.