Title: [149415] trunk/Source/WebCore
- Revision
- 149415
- Author
- [email protected]
- Date
- 2013-04-30 17:02:12 -0700 (Tue, 30 Apr 2013)
Log 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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149414 => 149415)
--- trunk/Source/WebCore/ChangeLog 2013-05-01 00:00:37 UTC (rev 149414)
+++ trunk/Source/WebCore/ChangeLog 2013-05-01 00:02:12 UTC (rev 149415)
@@ -1,5 +1,21 @@
2013-04-30 Anders Carlsson <[email protected]>
+ 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:
+
+2013-04-30 Anders Carlsson <[email protected]>
+
Clean up RunLoop code
https://bugs.webkit.org/show_bug.cgi?id=115454
Modified: trunk/Source/WebCore/platform/RunLoop.cpp (149414 => 149415)
--- trunk/Source/WebCore/platform/RunLoop.cpp 2013-05-01 00:00:37 UTC (rev 149414)
+++ trunk/Source/WebCore/platform/RunLoop.cpp 2013-05-01 00:02:12 UTC (rev 149415)
@@ -27,6 +27,7 @@
#include "RunLoop.h"
#include <wtf/StdLibExtras.h>
+#include <wtf/ThreadSpecific.h>
namespace WebCore {
@@ -38,6 +39,20 @@
static RunLoop* s_mainRunLoop;
+// Helper class for ThreadSpecificData.
+class RunLoop::Holder {
+public:
+ Holder()
+ : m_runLoop(adoptRef(new RunLoop))
+ {
+ }
+
+ RunLoop* runLoop() const { return m_runLoop.get(); }
+
+private:
+ RefPtr<RunLoop> m_runLoop;
+};
+
void RunLoop::initializeMainRunLoop()
{
if (s_mainRunLoop)
@@ -47,8 +62,8 @@
RunLoop* RunLoop::current()
{
- DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop>, runLoopData, ());
- return &*runLoopData;
+ DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<RunLoop::Holder>, runLoopHolder, ());
+ return runLoopHolder->runLoop();
}
RunLoop* RunLoop::main()
Modified: trunk/Source/WebCore/platform/RunLoop.h (149414 => 149415)
--- trunk/Source/WebCore/platform/RunLoop.h 2013-05-01 00:00:37 UTC (rev 149414)
+++ trunk/Source/WebCore/platform/RunLoop.h 2013-05-01 00:02:12 UTC (rev 149415)
@@ -33,7 +33,6 @@
#include <wtf/Functional.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
-#include <wtf/ThreadSpecific.h>
#include <wtf/Threading.h>
#if PLATFORM(GTK)
@@ -46,7 +45,7 @@
namespace WebCore {
-class RunLoop {
+class RunLoop : public ThreadSafeRefCounted<RunLoop> {
public:
// Must be called from the main thread (except for the Mac platform, where it
// can be called from any thread).
@@ -57,6 +56,7 @@
static RunLoop* current();
static RunLoop* main();
+ ~RunLoop();
void dispatch(const Function<void()>&);
@@ -130,11 +130,10 @@
TimerFiredFunction m_function;
};
-private:
- friend class WTF::ThreadSpecific<RunLoop>;
+ class Holder;
+private:
RunLoop();
- ~RunLoop();
void performWork();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes