Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: include/core/SkOnce.h

Issue 247813005: teach TSAN about SkSpinlock, SkRefCnt, and SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unused Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkOnce.h
diff --git a/include/core/SkOnce.h b/include/core/SkOnce.h
index d5330b94087a1d52e2ce8336747e0642075f8523..a42e7022f5a2058c99e7d2e60abc9e6f82cd9c10 100644
--- a/include/core/SkOnce.h
+++ b/include/core/SkOnce.h
@@ -54,10 +54,12 @@ struct SkSpinlock {
while (!sk_atomic_cas(&thisIsPrivate, 0, 1)) {
// spin
}
+ SK_ANNOTATE_RWLOCK_ACQUIRED(this, true);
}
void release() {
SkASSERT(shouldBeZero == 0);
+ SK_ANNOTATE_RWLOCK_RELEASED(this, true);
// This requires a release memory barrier before storing, which sk_atomic_cas guarantees.
SkAssertResult(sk_atomic_cas(&thisIsPrivate, 1, 0));
}
@@ -145,6 +147,7 @@ static void sk_once_slow(bool* done, Lock* lock, Func f, Arg arg, void (*atExit)
// observable whenever we observe *done == true.
release_barrier();
*done = true;
+ SK_ANNOTATE_HAPPENS_BEFORE(done);
}
}
@@ -165,6 +168,7 @@ inline void SkOnce(bool* done, Lock* lock, Func f, Arg arg, void(*atExit)()) {
// happens after f(arg), so by syncing to once->done = true here we're
// forcing ourselves to also wait until the effects of f(arg) are readble.
acquire_barrier();
+ SK_ANNOTATE_HAPPENS_AFTER(done);
}
template <typename Func, typename Arg>

Powered by Google App Engine
This is Rietveld 408576698