aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-02-29 10:14:38 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-29 10:14:38 -0800
commit15923c9e475894d89028b7a6a0b38aeeb9f9e645 (patch)
tree021ee7e8ff6cb8f07301e0f9b68017c29d92b0fe /dm
parent1e83a2a239a09cf5f128c18ff559916757a7c719 (diff)
Modernize SkSpinlock.
- Use std::atomic directly. - No more need for SkPODSpinlock or SK_DECLARE_STATIC_SPINLOCK. Now simple code like this works as you'd hope: static SkSpinlock gLock; That is, it starts unlocked and there's no static initializer. std::atomic_flag would make this terser and standard-guaranteed, but ATOMIC_FLAG_INIT caused not-yet-implemented errors on MSVC 2013. The generated code for this approach is identical. It appears the implicit constructor is constexpr when all the member initializers are. I'm hoping this way of producing constexpr constructors without typing "constexpr" gives us a way to eliminate more SkFoo / SkBaseFoo distinctions and SK_DECLARE_STATIC_FOO. This was certainly the easiest. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734383002 Review URL: https://codereview.chromium.org/1734383002
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 9173bb7858..4279ea37eb 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -84,7 +84,7 @@ static void fail(const SkString& err) {
// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
-SK_DECLARE_STATIC_SPINLOCK(gMutex);
+static SkSpinlock gMutex;
static int32_t gPending;
static SkTArray<SkString> gRunning;
@@ -92,7 +92,7 @@ static void done(const char* config, const char* src, const char* srcOptions, co
SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
int pending;
{
- SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
+ SkAutoTAcquire<SkSpinlock> lock(gMutex);
for (int i = 0; i < gRunning.count(); i++) {
if (gRunning[i] == id) {
gRunning.removeShuffle(i);
@@ -110,7 +110,7 @@ static void done(const char* config, const char* src, const char* srcOptions, co
static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
- SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
+ SkAutoTAcquire<SkSpinlock> lock(gMutex);
gRunning.push_back(id);
}
@@ -121,7 +121,7 @@ static void print_status() {
peak = sk_tools::getMaxResidentSetSizeMB();
SkString elapsed = HumanizeMs(SkTime::GetMSecs() - start_ms);
- SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
+ SkAutoTAcquire<SkSpinlock> lock(gMutex);
SkDebugf("\n%s elapsed, %d active, %d queued, %dMB RAM, %dMB peak\n",
elapsed.c_str(), gRunning.count(), gPending - gRunning.count(), curr, peak);
for (auto& task : gRunning) {
@@ -1242,7 +1242,7 @@ int dm_main() {
if (src->veto(sink->flags()) ||
is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
src.options.c_str(), src->name().c_str())) {
- SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
+ SkAutoTAcquire<SkSpinlock> lock(gMutex);
gPending--;
continue;
}