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

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

Issue 2680843006: Tidy DEFINE_(THREAD_SAFE_)STATIC_LOCAL() implementations. (Closed)
Patch Set: simplify DEFINE_THREAD_SAFE_STATIC_LOCAL() 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/Threading.h
diff --git a/third_party/WebKit/Source/wtf/Threading.h b/third_party/WebKit/Source/wtf/Threading.h
index 4a884824f2d0cb935dff9c672e6eeca7435e7d46..784470c708f8127ea9ce008e5513abf44b03d130 100644
--- a/third_party/WebKit/Source/wtf/Threading.h
+++ b/third_party/WebKit/Source/wtf/Threading.h
@@ -35,25 +35,6 @@
#include "wtf/WTFExport.h"
#include <stdint.h>
-// For portability, we do not make use of C++11 thread-safe statics, as
-// supported by some toolchains. Make use of double-checked locking to reduce
-// overhead. Note that this uses system-wide default lock, and cannot be used
-// before WTF::initializeThreading() is called.
-#define DEFINE_THREAD_SAFE_STATIC_LOCAL(T, name, initializer) \
- static_assert(!WTF::IsGarbageCollectedType<T>::value, \
- "Garbage collected types should not be a static local!"); \
- /* Init to nullptr is thread-safe on all implementations. */ \
- static void* name##Pointer = nullptr; \
- if (!WTF::acquireLoad(&name##Pointer)) { \
- WTF::lockAtomicallyInitializedStaticMutex(); \
- if (!WTF::acquireLoad(&name##Pointer)) { \
- std::remove_const<T>::type* initializerResult = initializer; \
- WTF::releaseStore(&name##Pointer, initializerResult); \
- } \
- WTF::unlockAtomicallyInitializedStaticMutex(); \
- } \
- T& name = *static_cast<T*>(name##Pointer)
-
namespace WTF {
#if OS(WIN)
@@ -68,11 +49,7 @@ WTF_EXPORT ThreadIdentifier currentThreadSyscall();
WTF_EXPORT ThreadIdentifier currentThread();
-WTF_EXPORT void lockAtomicallyInitializedStaticMutex();
-WTF_EXPORT void unlockAtomicallyInitializedStaticMutex();
-
#if DCHECK_IS_ON()
-WTF_EXPORT bool isAtomicallyInitializedStaticMutexLockHeld();
WTF_EXPORT bool isBeforeThreadCreated();
WTF_EXPORT void willCreateThread();
#endif

Powered by Google App Engine
This is Rietveld 408576698