| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
| 37 | 37 |
| 38 namespace WTF { | 38 namespace WTF { |
| 39 | 39 |
| 40 class AtomicStringTable; | 40 class AtomicStringTable; |
| 41 struct ICUConverterWrapper; | 41 struct ICUConverterWrapper; |
| 42 | 42 |
| 43 typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); | 43 typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); |
| 44 | 44 |
| 45 class WTF_EXPORT WTFThreadData { | 45 class WTF_EXPORT WTFThreadData { |
| 46 WTF_MAKE_NONCOPYABLE(WTFThreadData); | 46 WTF_MAKE_NONCOPYABLE(WTFThreadData); |
| 47 public: | |
| 48 WTFThreadData(); | |
| 49 ~WTFThreadData(); | |
| 50 | 47 |
| 51 AtomicStringTable* atomicStringTable() | 48 public: |
| 52 { | 49 WTFThreadData(); |
| 53 return m_atomicStringTable; | 50 ~WTFThreadData(); |
| 54 } | |
| 55 | 51 |
| 56 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } | 52 AtomicStringTable* atomicStringTable() { |
| 53 return m_atomicStringTable; |
| 54 } |
| 57 | 55 |
| 58 private: | 56 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } |
| 59 AtomicStringTable* m_atomicStringTable; | |
| 60 AtomicStringTableDestructor m_atomicStringTableDestructor; | |
| 61 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; | |
| 62 | 57 |
| 63 static ThreadSpecific<WTFThreadData>* staticData; | 58 private: |
| 64 friend WTFThreadData& wtfThreadData(); | 59 AtomicStringTable* m_atomicStringTable; |
| 65 friend class AtomicStringTable; | 60 AtomicStringTableDestructor m_atomicStringTableDestructor; |
| 61 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; |
| 62 |
| 63 static ThreadSpecific<WTFThreadData>* staticData; |
| 64 friend WTFThreadData& wtfThreadData(); |
| 65 friend class AtomicStringTable; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 inline WTFThreadData& wtfThreadData() | 68 inline WTFThreadData& wtfThreadData() { |
| 69 { | 69 // WRT WebCore: |
| 70 // WRT WebCore: | 70 // WTFThreadData is used on main thread before it could possibly be used |
| 71 // WTFThreadData is used on main thread before it could possibly be used | 71 // on secondary ones, so there is no need for synchronization here. |
| 72 // on secondary ones, so there is no need for synchronization here. | 72 // WRT JavaScriptCore: |
| 73 // WRT JavaScriptCore: | 73 // wtfThreadData() is initially called from initializeThreading(), ensuring |
| 74 // wtfThreadData() is initially called from initializeThreading(), ensuri
ng | 74 // this is initially called in a pthread_once locked context. |
| 75 // this is initially called in a pthread_once locked context. | 75 if (!WTFThreadData::staticData) |
| 76 if (!WTFThreadData::staticData) | 76 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; |
| 77 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; | 77 return **WTFThreadData::staticData; |
| 78 return **WTFThreadData::staticData; | |
| 79 } | 78 } |
| 80 | 79 |
| 81 } // namespace WTF | 80 } // namespace WTF |
| 82 | 81 |
| 83 using WTF::WTFThreadData; | 82 using WTF::WTFThreadData; |
| 84 using WTF::wtfThreadData; | 83 using WTF::wtfThreadData; |
| 85 | 84 |
| 86 #endif // WTFThreadData_h | 85 #endif // WTFThreadData_h |
| OLD | NEW |