OLD | NEW |
1 #ifndef DMReporter_DEFINED | 1 #ifndef DMReporter_DEFINED |
2 #define DMReporter_DEFINED | 2 #define DMReporter_DEFINED |
3 | 3 |
4 #include "SkString.h" | 4 #include "SkString.h" |
5 #include "SkTArray.h" | 5 #include "SkTArray.h" |
6 #include "SkThread.h" | 6 #include "SkThread.h" |
7 #include "SkTime.h" | 7 #include "SkTime.h" |
8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 | 9 |
10 // Used to report status changes including failures. All public methods are thr
eadsafe. | 10 // Used to report status changes including failures. All public methods are thr
eadsafe. |
11 namespace DM { | 11 namespace DM { |
12 | 12 |
13 class Reporter : SkNoncopyable { | 13 class Reporter : SkNoncopyable { |
14 public: | 14 public: |
15 Reporter() : fStarted(0), fFinished(0) {} | 15 Reporter() : fPending(0), fFailed(0) {} |
16 | 16 |
17 void start() { sk_atomic_inc(&fStarted); } | 17 void taskCreated() { sk_atomic_inc(&fPending); } |
18 void finish(SkString name, SkMSec timeMs); | 18 void taskDestroyed() { sk_atomic_dec(&fPending); } |
19 void fail(SkString msg); | 19 void fail(SkString msg); |
20 | 20 |
21 int32_t started() const { return fStarted; } | 21 void printStatus(SkString name, SkMSec timeMs) const; |
22 int32_t finished() const { return fFinished; } | |
23 int32_t failed() const; | |
24 | 22 |
25 void getFailures(SkTArray<SkString>*) const; | 23 void getFailures(SkTArray<SkString>*) const; |
26 | 24 |
27 private: | 25 private: |
28 int32_t fStarted, fFinished; | 26 int32_t fPending; // atomic |
| 27 int32_t fFailed; // atomic, == fFailures.count(). |
29 | 28 |
30 mutable SkMutex fMutex; // Guards fFailures. | 29 mutable SkMutex fMutex; // Guards fFailures. |
31 SkTArray<SkString> fFailures; | 30 SkTArray<SkString> fFailures; |
32 }; | 31 }; |
33 | 32 |
34 | 33 |
35 } // namespace DM | 34 } // namespace DM |
36 | 35 |
37 #endif // DMReporter_DEFINED | 36 #endif // DMReporter_DEFINED |
OLD | NEW |