OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkOnce.h" | 8 #include "SkOnce.h" |
9 #include "SkRunnable.h" | 9 #include "SkRunnable.h" |
10 #include "SkTaskGroup.h" | 10 #include "SkTaskGroup.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 *x += 6; | 32 *x += 6; |
33 } | 33 } |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 class Racer : public SkRunnable { | 37 class Racer : public SkRunnable { |
38 public: | 38 public: |
39 SkOnceFlag* once; | 39 SkOnceFlag* once; |
40 int* ptr; | 40 int* ptr; |
41 | 41 |
42 void run() SK_OVERRIDE { | 42 void run() override { |
43 SkOnce(once, add_six, ptr); | 43 SkOnce(once, add_six, ptr); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 SK_DECLARE_STATIC_ONCE(mt_once); | 49 SK_DECLARE_STATIC_ONCE(mt_once); |
50 DEF_TEST(SkOnce_Multithreaded, r) { | 50 DEF_TEST(SkOnce_Multithreaded, r) { |
51 const int kTasks = 16; | 51 const int kTasks = 16; |
52 | 52 |
(...skipping 19 matching lines...) Expand all Loading... |
72 static int gX = 0; | 72 static int gX = 0; |
73 static void inc_gX() { gX++; } | 73 static void inc_gX() { gX++; } |
74 | 74 |
75 SK_DECLARE_STATIC_ONCE(noarg_once); | 75 SK_DECLARE_STATIC_ONCE(noarg_once); |
76 DEF_TEST(SkOnce_NoArg, r) { | 76 DEF_TEST(SkOnce_NoArg, r) { |
77 SkOnce(&noarg_once, inc_gX); | 77 SkOnce(&noarg_once, inc_gX); |
78 SkOnce(&noarg_once, inc_gX); | 78 SkOnce(&noarg_once, inc_gX); |
79 SkOnce(&noarg_once, inc_gX); | 79 SkOnce(&noarg_once, inc_gX); |
80 REPORTER_ASSERT(r, 1 == gX); | 80 REPORTER_ASSERT(r, 1 == gX); |
81 } | 81 } |
OLD | NEW |