diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-23 14:44:08 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-23 14:44:08 +0000 |
commit | 1f81fd6546c111e21bc665657e976b9d842192df (patch) | |
tree | 00bb18a731ed166d187c864f2e5542a4996e5767 /tests/OnceTest.cpp | |
parent | fbcd415aa01801df5f554963d7463649b49ead73 (diff) |
SK_ONCE for SkData and SkPathRef
Adds SK_ONCE_FRIEND, to allow SK_DEF_ONCE code to be friends with a class. This had to go in include/core to be visible to headers there.
BUG=
R=reed@google.com, bungeman@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/26491003
git-svn-id: http://skia.googlecode.com/svn/trunk@11914 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/OnceTest.cpp')
-rw-r--r-- | tests/OnceTest.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp index 6c485a0f0a..31c6a85a44 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; } |