mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #ifndef DMReporter_DEFINED |
| 2 | #define DMReporter_DEFINED |
| 3 | |
| 4 | #include "SkString.h" |
| 5 | #include "SkTArray.h" |
| 6 | #include "SkThread.h" |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 7 | #include "SkTime.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 8 | #include "SkTypes.h" |
| 9 | |
| 10 | // Used to report status changes including failures. All public methods are threadsafe. |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 11 | namespace DM { |
| 12 | |
| 13 | class Reporter : SkNoncopyable { |
| 14 | public: |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 15 | Reporter() : fPending(0), fFailed(0) {} |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 16 | |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 17 | void taskCreated() { sk_atomic_inc(&fPending); } |
| 18 | void taskDestroyed() { sk_atomic_dec(&fPending); } |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 19 | void fail(SkString msg); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 20 | |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 21 | void printStatus(SkString name, SkMSec timeMs) const; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 22 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 23 | void getFailures(SkTArray<SkString>*) const; |
| 24 | |
| 25 | private: |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 26 | int32_t fPending; // atomic |
| 27 | int32_t fFailed; // atomic, == fFailures.count(). |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 28 | |
| 29 | mutable SkMutex fMutex; // Guards fFailures. |
| 30 | SkTArray<SkString> fFailures; |
| 31 | }; |
| 32 | |
| 33 | |
| 34 | } // namespace DM |
| 35 | |
| 36 | #endif // DMReporter_DEFINED |