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

Unified Diff: third_party/WebKit/Source/wtf/ThreadSpecific.h

Issue 2627153004: Use TLS storage for thread ids in wtf/ThreadingPThreads (Closed)
Patch Set: remove unnecessary include (trybots prev) Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/Threading.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/ThreadSpecific.h
diff --git a/third_party/WebKit/Source/wtf/ThreadSpecific.h b/third_party/WebKit/Source/wtf/ThreadSpecific.h
index 5d7f6d26a9eba250c76907a791b1e34b80de2c5d..377a82f4e24e405aafb5c707a672de58ddc39ce6 100644
--- a/third_party/WebKit/Source/wtf/ThreadSpecific.h
+++ b/third_party/WebKit/Source/wtf/ThreadSpecific.h
@@ -224,11 +224,6 @@ inline void ThreadSpecific<T>::set(T* ptr) {
template <typename T>
inline void ThreadSpecific<T>::destroy(void* ptr) {
- // Never call destructors on the main thread.
- // This is fine because Blink no longer has a graceful shutdown sequence.
- if (isMainThread())
- return;
-
Data* data = static_cast<Data*>(ptr);
#if OS(POSIX)
@@ -238,6 +233,13 @@ inline void ThreadSpecific<T>::destroy(void* ptr) {
pthread_setspecific(data->owner->m_key, ptr);
#endif
+ // Never call destructors on the main thread. This is fine because Blink no
+ // longer has a graceful shutdown sequence. Be careful to call this function
+ // (which can be re-entrant) while the pointer is still set, to avoid lazily
+ // allocating WTFThreadData after it is destroyed.
+ if (isMainThread())
+ return;
+
data->value->~T();
Partitions::fastFree(data->value);
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/Threading.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698