2013-10-16 13:02:15 +00:00
|
|
|
#ifndef DMReporter_DEFINED
|
|
|
|
#define DMReporter_DEFINED
|
|
|
|
|
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
#include "SkThread.h"
|
2014-03-03 15:44:56 +00:00
|
|
|
#include "SkTime.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
// Used to report status changes including failures. All public methods are threadsafe.
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
class Reporter : SkNoncopyable {
|
|
|
|
public:
|
2014-05-29 20:14:48 +00:00
|
|
|
Reporter() : fPending(0), fFailed(0) {}
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2014-05-29 20:14:48 +00:00
|
|
|
void taskCreated() { sk_atomic_inc(&fPending); }
|
|
|
|
void taskDestroyed() { sk_atomic_dec(&fPending); }
|
2014-02-26 16:31:22 +00:00
|
|
|
void fail(SkString msg);
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2014-05-29 20:14:48 +00:00
|
|
|
void printStatus(SkString name, SkMSec timeMs) const;
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
void getFailures(SkTArray<SkString>*) const;
|
|
|
|
|
|
|
|
private:
|
2014-05-29 20:14:48 +00:00
|
|
|
int32_t fPending; // atomic
|
|
|
|
int32_t fFailed; // atomic, == fFailures.count().
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
mutable SkMutex fMutex; // Guards fFailures.
|
|
|
|
SkTArray<SkString> fFailures;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#endif // DMReporter_DEFINED
|