Changeset 149415 in webkit
- Timestamp:
- Apr 30, 2013, 5:02:12 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149410 r149415 1 2013-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 1 17 2013-04-30 Anders Carlsson <andersca@apple.com> 2 18 -
trunk/Source/WebCore/platform/RunLoop.cpp
r149410 r149415 28 28 29 29 #include <wtf/StdLibExtras.h> 30 #include <wtf/ThreadSpecific.h> 30 31 31 32 namespace WebCore { … … 39 40 static RunLoop* s_mainRunLoop; 40 41 42 // Helper class for ThreadSpecificData. 43 class RunLoop::Holder { 44 public: 45 Holder() 46 : m_runLoop(adoptRef(new RunLoop)) 47 { 48 } 49 50 RunLoop* runLoop() const { return m_runLoop.get(); } 51 52 private: 53 RefPtr<RunLoop> m_runLoop; 54 }; 55 41 56 void RunLoop::initializeMainRunLoop() 42 57 { … … 48 63 RunLoop* RunLoop::current() 49 64 { 50 DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop >, runLoopData, ());51 return &*runLoopData;65 DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop::Holder>, runLoopHolder, ()); 66 return runLoopHolder->runLoop(); 52 67 } 53 68 -
trunk/Source/WebCore/platform/RunLoop.h
r149410 r149415 34 34 #include <wtf/HashMap.h> 35 35 #include <wtf/RetainPtr.h> 36 #include <wtf/ThreadSpecific.h>37 36 #include <wtf/Threading.h> 38 37 … … 47 46 namespace WebCore { 48 47 49 class RunLoop {48 class RunLoop : public ThreadSafeRefCounted<RunLoop> { 50 49 public: 51 50 // Must be called from the main thread (except for the Mac platform, where it … … 58 57 static RunLoop* current(); 59 58 static RunLoop* main(); 59 ~RunLoop(); 60 60 61 61 void dispatch(const Function<void()>&); … … 131 131 }; 132 132 133 class Holder; 134 133 135 private: 134 friend class WTF::ThreadSpecific<RunLoop>;135 136 136 RunLoop(); 137 ~RunLoop();138 137 139 138 void performWork();
Note:
See TracChangeset
for help on using the changeset viewer.