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

Unified Diff: src/isolate.cc

Issue 2887193002: Create a thread safe version of StatsCounters and use. (Closed)
Patch Set: Factor out base class StatsCounterBase Created 3 years, 7 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 | « src/isolate.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 3154f72ac3d303d7c423c3eded8f2cfd6f993606..8126bebc0b9a2d664a46d9d2b5ecea15134cabb6 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2549,7 +2549,6 @@ Isolate::~Isolate() {
delete logger_;
logger_ = NULL;
- delete counters_;
counters_ = NULL;
delete handle_scope_implementer_;
@@ -2635,14 +2634,22 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
return true;
}
+static base::LazyMutex initialize_counters_mutex = LAZY_MUTEX_INITIALIZER;
+
+bool Isolate::InitializeCounters() {
+ if (counters_ != NULL) return false;
jochen (gone - plz use gerrit) 2017/05/24 19:41:07 nit. nullptr
kschimpf 2017/05/24 20:26:09 Done.
+ base::LockGuard<base::Mutex> guard(initialize_counters_mutex.Pointer());
+ if (counters_ != NULL) return false;
+ counters_shared_ = std::make_shared<Counters>(this);
+ counters_ = counters_shared_.get();
+ return true;
+}
void Isolate::InitializeLoggingAndCounters() {
if (logger_ == NULL) {
logger_ = new Logger(this);
}
- if (counters_ == NULL) {
- counters_ = new Counters(this);
- }
+ InitializeCounters();
}
« no previous file with comments | « src/isolate.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698