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

Unified Diff: tests/skia_test.cpp

Issue 25357002: In skia_test.cc, atomics -> mutex. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/skia_test.cpp
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index a93b30797281ae7b40ad408fbd3fff420b53f708..620cdac9ca69fad6d075c6d1ef5c3bb908e0c0e2 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -84,20 +84,23 @@ public:
protected:
virtual void onStart(Test* test) {
- const int index = sk_atomic_inc(&fNextIndex)+1;
- const int pending = sk_atomic_inc(&fPending)+1;
- SkDebugf("[%3d/%3d] (%d) %s\n", index, fTotal, pending, test->getName());
+ SkAutoMutexAcquire lock(fStartEndMutex);
+ fNextIndex++;
+ fPending++;
+ SkDebugf("[%3d/%3d] (%d) %s\n", fNextIndex, fTotal, fPending, test->getName());
}
+
virtual void onReportFailed(const SkString& desc) {
SkDebugf("\tFAILED: %s\n", desc.c_str());
}
virtual void onEnd(Test* test) {
+ SkAutoMutexAcquire lock(fStartEndMutex);
if (!test->passed()) {
SkDebugf("---- %s FAILED\n", test->getName());
}
- sk_atomic_dec(&fPending);
+ fPending--;
if (fNextIndex == fTotal) {
// Just waiting on straggler tests. Shame them by printing their name and runtime.
SkDebugf(" (%d) %5.1fs %s\n",
@@ -106,8 +109,11 @@ protected:
}
private:
+ SkMutex fStartEndMutex; // Guards fNextIndex and fPending.
int32_t fNextIndex;
int32_t fPending;
+
+ // Once the tests get going, these are logically const.
int fTotal;
bool fAllowExtendedTest;
bool fAllowThreaded;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698