skia2/dm/DMReporter.h
commit-bot@chromium.org 39e8d93337 DM tweaks
- Don't print status updates for skipped tasks or count them as pending tasks.
 - Refactor DMReporter a bit for better symmetry, be more explicit about
   how we read atomics (that is, approximately) in printStatus() (née finish()).
 - Remove mutex locking from printStatus().

BUG=skia:
R=halcanary@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/309483003

git-svn-id: http://skia.googlecode.com/svn/trunk@14977 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-05-29 20:14:48 +00:00

37 lines
839 B
C++

#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() : fPending(0), fFailed(0) {}
void taskCreated() { sk_atomic_inc(&fPending); }
void taskDestroyed() { sk_atomic_dec(&fPending); }
void fail(SkString msg);
void printStatus(SkString name, SkMSec timeMs) const;
void getFailures(SkTArray<SkString>*) const;
private:
int32_t fPending; // atomic
int32_t fFailed; // atomic, == fFailures.count().
mutable SkMutex fMutex; // Guards fFailures.
SkTArray<SkString> fFailures;
};
} // namespace DM
#endif // DMReporter_DEFINED