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