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

Side by Side Diff: tests/OnceTest.cpp

Issue 132803005: SkOnce: add option to call another cleanup function once at exit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add static Created 6 years, 10 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 | « tests/CachedDecodingPixelRefTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkThreadPool.h" 9 #include "SkThreadPool.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Let them race. 70 // Let them race.
71 SkThreadPool pool(kThreads); 71 SkThreadPool pool(kThreads);
72 for (int i = 0; i < kTasks; i++) { 72 for (int i = 0; i < kTasks; i++) {
73 pool.add(&racers[i]); 73 pool.add(&racers[i]);
74 } 74 }
75 pool.wait(); 75 pool.wait();
76 76
77 // Only one should have done the +=. 77 // Only one should have done the +=.
78 REPORTER_ASSERT(r, 6 == x); 78 REPORTER_ASSERT(r, 6 == x);
79 } 79 }
80
81 // Test that the atExit option works.
82 static int gToDecrement = 1;
83 static void noop(int) {}
84 static void decrement() { gToDecrement--; }
85 static void checkDecremented() { SkASSERT(gToDecrement == 0); }
86
87 DEF_TEST(SkOnce_atExit, r) {
88 atexit(checkDecremented);
89 SK_DECLARE_STATIC_ONCE(once);
90 SkOnce(&once, noop, 0, decrement);
91 }
OLDNEW
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698