Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: third_party/WebKit/Source/wtf/WTFThreadData.h

Issue 2646003003: Avoid checking for WTFThreadData::staticData in wtfThreadData() (Closed)
Patch Set: fix bad rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 public: 48 public:
49 WTFThreadData(); 49 WTFThreadData();
50 ~WTFThreadData(); 50 ~WTFThreadData();
51 51
52 AtomicStringTable& getAtomicStringTable() { return *m_atomicStringTable; } 52 AtomicStringTable& getAtomicStringTable() { return *m_atomicStringTable; }
53 53
54 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } 54 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
55 55
56 ThreadIdentifier threadId() const { return m_threadId; } 56 ThreadIdentifier threadId() const { return m_threadId; }
57 57
58 // Must be called on the main thread before any callers to wtfThreadData().
59 static void initialize();
60
58 #if OS(WIN) && COMPILER(MSVC) 61 #if OS(WIN) && COMPILER(MSVC)
59 static size_t threadStackSize(); 62 static size_t threadStackSize();
60 #endif 63 #endif
61 64
62 private: 65 private:
63 std::unique_ptr<AtomicStringTable> m_atomicStringTable; 66 std::unique_ptr<AtomicStringTable> m_atomicStringTable;
64 std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU; 67 std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU;
65 68
66 ThreadIdentifier m_threadId; 69 ThreadIdentifier m_threadId;
67 70
68 #if OS(WIN) && COMPILER(MSVC) 71 #if OS(WIN) && COMPILER(MSVC)
69 size_t m_threadStackSize = 0u; 72 size_t m_threadStackSize = 0u;
70 #endif 73 #endif
71 74
72 static ThreadSpecific<WTFThreadData>* staticData; 75 static ThreadSpecific<WTFThreadData>* staticData;
73 friend WTFThreadData& wtfThreadData(); 76 friend WTFThreadData& wtfThreadData();
74 }; 77 };
75 78
76 inline WTFThreadData& wtfThreadData() { 79 inline WTFThreadData& wtfThreadData() {
77 // WTFThreadData is used on main thread before it could possibly be used 80 DCHECK(WTFThreadData::staticData);
78 // on secondary ones, so there is no need for synchronization here.
79 if (!WTFThreadData::staticData)
80 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>;
81 return **WTFThreadData::staticData; 81 return **WTFThreadData::staticData;
82 } 82 }
83 83
84 } // namespace WTF 84 } // namespace WTF
85 85
86 using WTF::WTFThreadData; 86 using WTF::WTFThreadData;
87 using WTF::wtfThreadData; 87 using WTF::wtfThreadData;
88 88
89 #endif // WTFThreadData_h 89 #endif // WTFThreadData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadingWin.cpp ('k') | third_party/WebKit/Source/wtf/WTFThreadData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698