Index: third_party/WebKit/Source/wtf/WTFThreadData.h |
diff --git a/third_party/WebKit/Source/wtf/WTFThreadData.h b/third_party/WebKit/Source/wtf/WTFThreadData.h |
index a3351de1a4782adffc7051de70bf835f2becd445..bf49b3713a805ba87862a8058c3d510a763ef5f8 100644 |
--- a/third_party/WebKit/Source/wtf/WTFThreadData.h |
+++ b/third_party/WebKit/Source/wtf/WTFThreadData.h |
@@ -46,7 +46,8 @@ class WTF_EXPORT WTFThreadData { |
WTF_MAKE_NONCOPYABLE(WTFThreadData); |
public: |
- WTFThreadData(); |
+ enum ThreadType { MainThread, Other }; |
+ explicit WTFThreadData(ThreadType = Other); |
~WTFThreadData(); |
AtomicStringTable& getAtomicStringTable() { return *m_atomicStringTable; } |
@@ -55,27 +56,44 @@ class WTF_EXPORT WTFThreadData { |
ThreadIdentifier threadId() const { return m_threadId; } |
+#if OS(WIN) && COMPILER(MSVC) |
+ size_t threadStackSize(); |
+#endif |
+ |
+ static void initialize(); |
+ |
+ static WTFThreadData& current(); |
+ |
+ static bool isMainThread(); |
+ |
+ // Returns true if this is the main thread, via a stack address hueristic. |
+ // This is a subtle method and most callers should prefer isMainThread. |
+ static bool stackBasedIsMainThread(); |
haraken
2017/01/16 04:42:30
Let's mention that this may return false even if i
Charlie Harrison
2017/01/18 01:49:48
Done.
|
+ |
private: |
+ static WTFThreadData& mainThreadData(); |
+ // m_threadId must be initialized first, as following members need it for |
+ // initialization. |
+ const ThreadIdentifier m_threadId; |
+ |
+#if OS(WIN) && COMPILER(MSVC) |
+ size_t m_threadStackSize = 0u; |
+#endif |
+ |
std::unique_ptr<AtomicStringTable> m_atomicStringTable; |
std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU; |
- ThreadIdentifier m_threadId; |
+ static uintptr_t s_mainThreadStackStart; |
+ static uintptr_t s_mainThreadUnderestimatedStackSize; |
+ static uint8_t s_mainThreadDataStorage[]; |
static ThreadSpecific<WTFThreadData>* staticData; |
- friend WTFThreadData& wtfThreadData(); |
}; |
-inline WTFThreadData& wtfThreadData() { |
- // WTFThreadData is used on main thread before it could possibly be used |
- // on secondary ones, so there is no need for synchronization here. |
- if (!WTFThreadData::staticData) |
- WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; |
- return **WTFThreadData::staticData; |
-} |
+bool operator==(const WTFThreadData& data1, const WTFThreadData& data2); |
} // namespace WTF |
using WTF::WTFThreadData; |
-using WTF::wtfThreadData; |
#endif // WTFThreadData_h |