Chromium Code Reviews| 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..1dbd7ffdd0e8017a3cc1c6bc3f3087983b85be8a 100644 |
| --- a/third_party/WebKit/Source/wtf/ThreadSpecific.h |
| +++ b/third_party/WebKit/Source/wtf/ThreadSpecific.h |
| @@ -45,6 +45,7 @@ |
| #include "wtf/Allocator.h" |
| #include "wtf/Noncopyable.h" |
| #include "wtf/StdLibExtras.h" |
| +#include "wtf/Threading.h" |
|
Charlie Harrison
2017/01/13 16:38:45
Remove this.
Charlie Harrison
2017/01/13 16:56:55
Done.
|
| #include "wtf/WTF.h" |
| #include "wtf/WTFExport.h" |
| #include "wtf/allocator/PartitionAllocator.h" |
| @@ -224,11 +225,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 +234,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); |