[dm] Fix TSAN reports about "done"
Change-Id: Id153febe3bc2e4da0f487112c9f65ad2d715dc90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/836018
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 0ebdcf8..0bbe738 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -262,7 +262,9 @@
static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
- vlog("[%d/%d] %s done\n", gTotalCounts - gPending, gTotalCounts, id.c_str());
+ bool updateDueToProgress;
+ double lastUpdate;
+ int totalCounts;
int pending;
{
SkAutoSpinlock lock(gMutex);
@@ -272,14 +274,19 @@
break;
}
}
- pending = --gPending;
+ --gPending;
+ updateDueToProgress = gPending % 500 == 0;
+ lastUpdate = gLastUpdate;
+ totalCounts = gTotalCounts;
+ pending = gPending;
}
+ vlog("[%d/%d] %s done\n", totalCounts - pending, totalCounts, id.c_str());
// We write out dm.json file and print out a progress update every once in a while.
// Notice this also handles the final dm.json and progress update when pending == 0.
- double lastUpdate = gLastUpdate;
double now = SkTime::GetNSecs();
- if (pending % 500 == 0 || now - lastUpdate > 4e9) {
+ bool updateDueToTime = now - lastUpdate > 4e9;
+ if (updateDueToProgress || updateDueToTime) {
dump_json();
int curr = sk_tools::getCurrResidentSetSizeMB(),