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

Unified Diff: Source/wtf/ThreadingWin.cpp

Issue 874203002: Add a thread-safety assertion in DEFINE_STATIC_LOCAL (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 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
« Source/wtf/ThreadingPthreads.cpp ('K') | « Source/wtf/ThreadingPthreads.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/ThreadingWin.cpp
diff --git a/Source/wtf/ThreadingWin.cpp b/Source/wtf/ThreadingWin.cpp
index cc342571014f09a02c1ea9d3a519d4a42200e44c..06cd6b0f2b7e902cfb1026b1b6086b895a6a69a6 100644
--- a/Source/wtf/ThreadingWin.cpp
+++ b/Source/wtf/ThreadingWin.cpp
@@ -391,6 +391,33 @@ DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime)
return static_cast<DWORD>((absoluteTime - currentTime) * 1000.0);
}
+#if ENABLE(ASSERT)
+static bool s_threadCreated = false;
+
+struct ThreadCreationRecorder {
+ ThreadCreationRecorder()
+ {
+ ASSERT(!s_threadCreated);
+ s_threadCreated = true;
+ }
+};
+
+bool isAtomicallyInitializedStaticMutexLockHeld()
+{
+ return atomicallyInitializedStaticMutex && atomicallyInitializedStaticMutex->locked();
+}
+
+bool isBeforeThreadCreated()
+{
+ return !s_threadCreated;
+}
+
+void willCreateThread()
+{
+ static ThreadCreationRecorder recorder;
+}
+#endif
+
} // namespace WTF
#endif // OS(WIN)
« Source/wtf/ThreadingPthreads.cpp ('K') | « Source/wtf/ThreadingPthreads.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698