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

Unified Diff: Source/wtf/ThreadingPthreads.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
Index: Source/wtf/ThreadingPthreads.cpp
diff --git a/Source/wtf/ThreadingPthreads.cpp b/Source/wtf/ThreadingPthreads.cpp
index 2208ca4e9a863411ba69a3ee9b52c6c221a96ceb..91e7ef7889c6be5f20872e0de420234a3927543d 100644
--- a/Source/wtf/ThreadingPthreads.cpp
+++ b/Source/wtf/ThreadingPthreads.cpp
@@ -246,6 +246,33 @@ void ThreadCondition::broadcast()
ASSERT_UNUSED(result, !result);
}
+#if ENABLE(ASSERT)
+static bool s_threadCreated = false;
+
+struct ThreadCreationRecorder {
+ ThreadCreationRecorder()
+ {
+ ASSERT(!s_threadCreated);
eroman 2015/01/30 18:02:30 Not sure how valuable this assertion is. Probably
kinuko 2015/02/03 06:57:34 Done.
+ s_threadCreated = true;
+ }
+};
+
+bool isAtomicallyInitializedStaticMutexLockHeld()
+{
+ return atomicallyInitializedStaticMutex && atomicallyInitializedStaticMutex->locked();
+}
+
+bool isBeforeThreadCreated()
+{
+ return !s_threadCreated;
+}
+
+void willCreateThread()
+{
+ static ThreadCreationRecorder recorder;
+}
+#endif
+
} // namespace WTF
#endif // USE(PTHREADS)

Powered by Google App Engine
This is Rietveld 408576698