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

Unified Diff: tests/OnceTest.cpp

Issue 806473006: namespace {} trick for SK_DECLARE_STATIC_ONCE (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« src/utils/win/SkDWrite.cpp ('K') | « src/utils/win/SkDWrite.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/OnceTest.cpp
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index 6ab9cd27ac2ae4a906e6b4ff96513abc17b51d20..1344cee5c44e4f3b7da15e80662011e23237f4bc 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -14,16 +14,16 @@ static void add_five(int* x) {
*x += 5;
}
+SK_DECLARE_STATIC_ONCE(st_once);
DEF_TEST(SkOnce_Singlethreaded, r) {
int x = 0;
- SK_DECLARE_STATIC_ONCE(once);
// No matter how many times we do this, x will be 5.
- SkOnce(&once, add_five, &x);
- SkOnce(&once, add_five, &x);
- SkOnce(&once, add_five, &x);
- SkOnce(&once, add_five, &x);
- SkOnce(&once, add_five, &x);
+ SkOnce(&st_once, add_five, &x);
+ SkOnce(&st_once, add_five, &x);
+ SkOnce(&st_once, add_five, &x);
+ SkOnce(&st_once, add_five, &x);
+ SkOnce(&st_once, add_five, &x);
REPORTER_ASSERT(r, 5 == x);
}
@@ -46,15 +46,15 @@ public:
} // namespace
+SK_DECLARE_STATIC_ONCE(mt_once);
DEF_TEST(SkOnce_Multithreaded, r) {
const int kTasks = 16;
// Make a bunch of tasks that will race to be the first to add six to x.
Racer racers[kTasks];
- SK_DECLARE_STATIC_ONCE(once);
int x = 0;
for (int i = 0; i < kTasks; i++) {
- racers[i].once = &once;
+ racers[i].once = &mt_once;
racers[i].ptr = &x;
}
@@ -72,10 +72,10 @@ DEF_TEST(SkOnce_Multithreaded, r) {
static int gX = 0;
static void inc_gX() { gX++; }
+SK_DECLARE_STATIC_ONCE(noarg_once);
DEF_TEST(SkOnce_NoArg, r) {
- SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, inc_gX);
- SkOnce(&once, inc_gX);
- SkOnce(&once, inc_gX);
+ SkOnce(&noarg_once, inc_gX);
+ SkOnce(&noarg_once, inc_gX);
+ SkOnce(&noarg_once, inc_gX);
REPORTER_ASSERT(r, 1 == gX);
}
« src/utils/win/SkDWrite.cpp ('K') | « src/utils/win/SkDWrite.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698