| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/ThreadSpecific.h" | 33 #include "wtf/ThreadSpecific.h" |
| 34 #include "wtf/Threading.h" | 34 #include "wtf/Threading.h" |
| 35 #include "wtf/WTFExport.h" | 35 #include "wtf/WTFExport.h" |
| 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*); | |
| 44 | |
| 45 class WTF_EXPORT WTFThreadData { | 43 class WTF_EXPORT WTFThreadData { |
| 46 WTF_MAKE_NONCOPYABLE(WTFThreadData); | 44 WTF_MAKE_NONCOPYABLE(WTFThreadData); |
| 47 public: | 45 public: |
| 48 WTFThreadData(); | 46 WTFThreadData(); |
| 49 ~WTFThreadData(); | 47 ~WTFThreadData(); |
| 50 | 48 |
| 49 static void createData(); |
| 50 |
| 51 AtomicStringTable* atomicStringTable() | 51 AtomicStringTable* atomicStringTable() |
| 52 { | 52 { |
| 53 return m_atomicStringTable; | 53 return m_atomicStringTable; |
| 54 } | 54 } |
| 55 | 55 |
| 56 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } | 56 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 AtomicStringTable* m_atomicStringTable; | 59 AtomicStringTable* m_atomicStringTable; |
| 60 AtomicStringTableDestructor m_atomicStringTableDestructor; | |
| 61 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; | 60 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; |
| 62 | 61 |
| 63 static ThreadSpecific<WTFThreadData>* staticData; | 62 static ThreadSpecific<WTFThreadData>* s_staticData; |
| 64 friend WTFThreadData& wtfThreadData(); | 63 friend WTFThreadData& wtfThreadData(); |
| 65 friend class AtomicStringTable; | |
| 66 }; | 64 }; |
| 67 | 65 |
| 68 inline WTFThreadData& wtfThreadData() | 66 inline WTFThreadData& wtfThreadData() |
| 69 { | 67 { |
| 70 // WRT WebCore: | 68 ASSERT(WTFThreadData::s_staticData); |
| 71 // WTFThreadData is used on main thread before it could possibly be used | 69 return **WTFThreadData::s_staticData; |
| 72 // on secondary ones, so there is no need for synchronization here. | |
| 73 // WRT JavaScriptCore: | |
| 74 // wtfThreadData() is initially called from initializeThreading(), ensuri
ng | |
| 75 // this is initially called in a pthread_once locked context. | |
| 76 if (!WTFThreadData::staticData) | |
| 77 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; | |
| 78 return **WTFThreadData::staticData; | |
| 79 } | 70 } |
| 80 | 71 |
| 81 } // namespace WTF | 72 } // namespace WTF |
| 82 | 73 |
| 83 using WTF::WTFThreadData; | 74 using WTF::WTFThreadData; |
| 84 using WTF::wtfThreadData; | 75 using WTF::wtfThreadData; |
| 85 | 76 |
| 86 #endif // WTFThreadData_h | 77 #endif // WTFThreadData_h |
| OLD | NEW |