aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMReporter.h
blob: 3f8e953a71af71e7906f5e7c4bd60f9fa11933e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef DMReporter_DEFINED
#define DMReporter_DEFINED

#include "SkString.h"
#include "SkTArray.h"
#include "SkThread.h"
#include "SkTime.h"
#include "SkTypes.h"

// Used to report status changes including failures.  All public methods are threadsafe.
namespace DM {

class Reporter : SkNoncopyable {
public:
    Reporter() : fStarted(0), fFinished(0) {}

    void start()  { sk_atomic_inc(&fStarted); }
    void finish(SkString name, SkMSec timeMs);
    void fail(SkString msg);

    int32_t started()  const { return fStarted; }
    int32_t finished() const { return fFinished; }
    int32_t failed()   const;

    void getFailures(SkTArray<SkString>*) const;

private:
    int32_t fStarted, fFinished;

    mutable SkMutex fMutex;  // Guards fFailures.
    SkTArray<SkString> fFailures;
};


}  // namespace DM

#endif  // DMReporter_DEFINED