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

Unified Diff: tests/OnceTest.cpp

Issue 26491003: SK_ONCE for SkData (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: dropped assert Created 7 years, 2 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/core/SkPathRef.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 6c485a0f0ae35ba7e06be9aa3b376068a1ccaa7a..31c6a85a44cbd50213129f3c265ae8c71773cf55 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -10,32 +10,35 @@
#include "Test.h"
#include "TestClassDef.h"
-DEF_SK_ONCE(add_five, int* x) {
+static void add_five(int* x) {
*x += 5;
}
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.
- SK_ONCE(add_five, &x);
- SK_ONCE(add_five, &x);
- SK_ONCE(add_five, &x);
- SK_ONCE(add_five, &x);
- SK_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(&once, add_five, &x);
REPORTER_ASSERT(r, 5 == x);
}
-DEF_SK_ONCE(add_six, int* x) {
+static void add_six(int* x) {
*x += 6;
}
class Racer : public SkRunnable {
public:
+ SkOnceFlag* once;
int* ptr;
+
virtual void run() SK_OVERRIDE {
- SK_ONCE(add_six, ptr);
+ SkOnce(once, add_six, ptr);
}
};
@@ -44,8 +47,10 @@ DEF_TEST(SkOnce_Multithreaded, r) {
// 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].ptr = &x;
}
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698