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

Unified Diff: webrtc/base/race_checker.cc

Issue 2350663002: Change thread check to race check (Closed)
Patch Set: using RaceChecker instead Created 4 years, 3 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
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvoiceengine.cc » ('j') | webrtc/media/engine/webrtcvoiceengine.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/race_checker.cc
diff --git a/webrtc/base/race_checker.cc b/webrtc/base/race_checker.cc
index 9f0946ca76f87e1386219b21f8073676f3497a00..78d6a259b325d8599e1cbf0d2ed139e543d66300 100644
--- a/webrtc/base/race_checker.cc
+++ b/webrtc/base/race_checker.cc
@@ -14,6 +14,10 @@ namespace rtc {
RaceChecker::RaceChecker() {}
+// Note that the implementation here is in itself racy, but we pretend it does
+// not matter. If there is indeed a race (two threads both think access_count_
+// is zero) access_count_ will likely only be incremented once, but decremented
+// twice, causing the IsThreadRefEqual() check to return false at a later point.
kwiberg-webrtc 2016/09/20 19:29:07 It may be incremented once instead of twice, possi
pbos-webrtc 2016/09/20 19:36:02 If two threads use it, and anyone at any point wri
kwiberg-webrtc 2016/09/20 20:01:31 Yes, garbage in access_count_ shouldn't be a probl
bool RaceChecker::Acquire() const {
const PlatformThreadRef current_thread = CurrentThreadRef();
// Set new accessing thread if this is a new use.
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvoiceengine.cc » ('j') | webrtc/media/engine/webrtcvoiceengine.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698