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

Unified Diff: base/synchronization/waitable_event_posix.cc

Issue 1980743002: Track thread activities in order to diagnose hangs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@readwrite-mmf
Patch Set: more clean-up and addressed review comments Created 4 years, 6 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: base/synchronization/waitable_event_posix.cc
diff --git a/base/synchronization/waitable_event_posix.cc b/base/synchronization/waitable_event_posix.cc
index b32c882711638f497c7e260398c7eca265202565..7242e1609472b74328106a995a02e84d3448ca4c 100644
--- a/base/synchronization/waitable_event_posix.cc
+++ b/base/synchronization/waitable_event_posix.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <vector>
+#include "base/debug/activity_tracker.h"
#include "base/logging.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
@@ -157,6 +158,9 @@ void WaitableEvent::Wait() {
}
bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
+ // Record the event that this thread is blocking upon (for hang diagonsis).
manzagop (departed) 2016/06/16 15:19:41 typo: disgonsis, here and below.
+ base::debug::ScopedEventWaitActivity event_activity(this);
+
base::ThreadRestrictions::AssertWaitAllowed();
const TimeTicks end_time(TimeTicks::Now() + max_time);
const bool finite_time = max_time.ToInternalValue() >= 0;
@@ -229,6 +233,10 @@ cmp_fst_addr(const std::pair<WaitableEvent*, unsigned> &a,
// static
size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables,
size_t count) {
+ // Record the event that this thread is blocking upon (for hang diagonsis).
manzagop (departed) 2016/06/16 15:19:41 Can |count| be 0?
manzagop (departed) 2016/06/16 15:19:41 Make note only considering first event?
bcwhite 2016/06/16 17:04:43 There's a DCHECK(count) below, so no. But I shoul
+ // Extra parenthesis needed so C++ doesn't think this is a function prototype.
manzagop (departed) 2016/06/16 15:19:40 Dead comment?
bcwhite 2016/06/16 17:04:43 Done.
+ base::debug::ScopedEventWaitActivity event_activity(raw_waitables[0]);
+
base::ThreadRestrictions::AssertWaitAllowed();
DCHECK(count) << "Cannot wait on no events";

Powered by Google App Engine
This is Rietveld 408576698