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

Side by Side Diff: tests/LazyPtr.cpp

Issue 669783002: SkLazyPtr follow ups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: no static Created 6 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 unified diff | Download patch
« no previous file with comments | « src/core/SkLazyPtr.h ('k') | tests/LazyPtrTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "Test.h"
2 #include "SkLazyPtr.h"
3 #include "SkTaskGroup.h"
4
5 DEF_TEST(LazyPtr, r) {
6 SkLazyPtr<int> lazy;
7 int* ptr = lazy.get();
8
9 REPORTER_ASSERT(r, ptr);
10 REPORTER_ASSERT(r, lazy.get() == ptr);
11
12 SkLazyPtr<double> neverRead;
13 }
14
15 namespace {
16
17 struct Racer : public SkRunnable {
18 Racer() : fLazy(NULL), fSeen(NULL) {}
19
20 virtual void run() SK_OVERRIDE { fSeen = fLazy->get(); }
21
22 SkLazyPtr<int>* fLazy;
23 int* fSeen;
24 };
25
26 } // namespace
27
28 DEF_TEST(LazyPtr_Threaded, r) {
29 static const int kRacers = 321;
30
31 SkLazyPtr<int> lazy;
32
33 Racer racers[kRacers];
34 for (int i = 0; i < kRacers; i++) {
35 racers[i].fLazy = &lazy;
36 }
37
38 SkTaskGroup tg;
39 for (int i = 0; i < kRacers; i++) {
40 tg.add(racers + i);
41 }
42 tg.wait();
43
44 for (int i = 1; i < kRacers; i++) {
45 REPORTER_ASSERT(r, racers[i].fSeen);
46 REPORTER_ASSERT(r, racers[i].fSeen == racers[0].fSeen);
47 }
48 }
OLDNEW
« no previous file with comments | « src/core/SkLazyPtr.h ('k') | tests/LazyPtrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698