Move the shared LineBreakIteratorPool from ThreadGlobalData into its own ThreadSpecific
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Aug 2011 17:00:48 +0000 (17:00 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Aug 2011 17:00:48 +0000 (17:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65809

Reviewed by Darin Adler and Sam Weinig.

* platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::destroy): Removed code to clear the m_lineBreakIteratorPool member
variable, which was removed.
* platform/ThreadGlobalData.h: Removed lineBreakIteratorPool() and associated member variable.
* platform/text/LineBreakIteratorPoolICU.h:
(WebCore::LineBreakIteratorPool::sharedPool): Changed to return a thread-specific pool.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92553 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/ThreadGlobalData.cpp
Source/WebCore/platform/ThreadGlobalData.h
Source/WebCore/platform/text/LineBreakIteratorPoolICU.h

index b74e0ab79c568f3caf8958be98bb9a20ff5e895c..27374eb133682b2c66525b772a8711909241dbd9 100644 (file)
@@ -1,3 +1,17 @@
+2011-08-06  Dan Bernstein  <mitz@apple.com>
+
+        Move the shared LineBreakIteratorPool from ThreadGlobalData into its own ThreadSpecific
+        https://bugs.webkit.org/show_bug.cgi?id=65809
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        * platform/ThreadGlobalData.cpp:
+        (WebCore::ThreadGlobalData::destroy): Removed code to clear the m_lineBreakIteratorPool member
+        variable, which was removed.
+        * platform/ThreadGlobalData.h: Removed lineBreakIteratorPool() and associated member variable.
+        * platform/text/LineBreakIteratorPoolICU.h:
+        (WebCore::LineBreakIteratorPool::sharedPool): Changed to return a thread-specific pool.
+
 2011-08-06  Joseph Pecoraro  <joepeck@webkit.org>
 
         Potential Leaks - RetainPtr<> over retaining Create'd objects
index 195db7cba9892996b4368efea2bc72548b8cf81c..a97a7783749e62684c536b545c155d740696c2bd 100644 (file)
@@ -35,7 +35,6 @@
 #include <wtf/text/StringImpl.h>
 
 #if USE(ICU_UNICODE)
-#include "LineBreakIteratorPoolICU.h"
 #include "TextCodecICU.h"
 #endif
 
@@ -83,15 +82,6 @@ ThreadGlobalData::~ThreadGlobalData()
     destroy();
 }
 
-#if USE(ICU_UNICODE)
-LineBreakIteratorPool& ThreadGlobalData::lineBreakIteratorPool()
-{
-    if (!m_lineBreakIteratorPool)
-        m_lineBreakIteratorPool = LineBreakIteratorPool::create();
-    return *m_lineBreakIteratorPool;
-}
-#endif
-
 void ThreadGlobalData::destroy()
 {
 #if PLATFORM(MAC)
@@ -102,7 +92,6 @@ void ThreadGlobalData::destroy()
 #if USE(ICU_UNICODE)
     delete m_cachedConverterICU;
     m_cachedConverterICU = 0;
-    m_lineBreakIteratorPool = nullptr;
 #endif
 
     delete m_eventNames;
index d1556367a8f3c6d0a0a52b706deb3a22dcc8877a..8949c3003d1442280519645b408110187d3966db 100644 (file)
@@ -42,7 +42,6 @@ using WTF::ThreadSpecific;
 namespace WebCore {
 
     class EventNames;
-    class LineBreakIteratorPool;
     class ThreadTimers;
 
     struct ICUConverterWrapper;
@@ -60,7 +59,6 @@ namespace WebCore {
 
 #if USE(ICU_UNICODE)
         ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
-        LineBreakIteratorPool& lineBreakIteratorPool();
 #endif
 
 #if PLATFORM(MAC)
@@ -77,7 +75,6 @@ namespace WebCore {
 
 #if USE(ICU_UNICODE)
         ICUConverterWrapper* m_cachedConverterICU;
-        OwnPtr<LineBreakIteratorPool> m_lineBreakIteratorPool;
 #endif
 
 #if PLATFORM(MAC)
index 11b1150312d9638c1ee7da0491ba6e9df59edd77..d8e2ccbcd8f11a817de3da413eeae1d404eb72e9 100644 (file)
 #define LineBreakIteratorPoolICU_h
 
 #include "TextBreakIteratorInternalICU.h"
-#include "ThreadGlobalData.h"
 #include <unicode/ubrk.h>
 #include <wtf/Assertions.h>
 #include <wtf/HashMap.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/ThreadSpecific.h>
+#include <wtf/text/AtomicString.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
@@ -41,7 +42,8 @@ class LineBreakIteratorPool {
 public:
     static LineBreakIteratorPool& sharedPool()
     {
-        return threadGlobalData().lineBreakIteratorPool();
+        static WTF::ThreadSpecific<LineBreakIteratorPool>* pool = new WTF::ThreadSpecific<LineBreakIteratorPool>;
+        return **pool;
     }
 
     static PassOwnPtr<LineBreakIteratorPool> create() { return adoptPtr(new LineBreakIteratorPool); }
@@ -92,6 +94,8 @@ private:
     typedef Vector<Entry, capacity> Pool;
     Pool m_pool;
     HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
+
+    friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIteratorPool*();
 };
 
 }