aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSpinlock.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-07-09 10:51:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-09 10:51:36 -0700
commit828877d7267bcb7c272a1df4e36a6a79894bf00d (patch)
tree3318a7c52ab29d10887412dc2e6733e5d99f506f /src/core/SkSpinlock.cpp
parentaf4edf9ccc274bef118b268145e0d1ae25072a5f (diff)
Outline SkSpinlock::acquire().
The proportion of time spent doing useful work is well over 99% in acquire(), so outlining it doesn't hurt speed at all, and makes it much easier to pick out on a profile. It'd be about 50/50 work/overhead if we outlined the extremely-cheap release(). I also tried outlining some SkRefCnt methods with similar mixed results. BUG=skia: No public API changes. TBR=reed@google.com Review URL: https://codereview.chromium.org/1212253013
Diffstat (limited to 'src/core/SkSpinlock.cpp')
-rw-r--r--src/core/SkSpinlock.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/SkSpinlock.cpp b/src/core/SkSpinlock.cpp
new file mode 100644
index 0000000000..0f764278df
--- /dev/null
+++ b/src/core/SkSpinlock.cpp
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkSpinlock.h"
+
+void SkPODSpinlock::contendedAcquire() {
+ // To act as a mutex, we need an acquire barrier when we take the lock.
+ while(sk_atomic_exchange(&fLocked, true, sk_memory_order_acquire)) { /*spin*/ }
+}