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

Unified Diff: base/synchronization/waitable_event_win.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: rebased Created 4 years, 4 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 | « base/synchronization/waitable_event_posix.cc ('k') | base/threading/platform_thread_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/waitable_event_win.cc
diff --git a/base/synchronization/waitable_event_win.cc b/base/synchronization/waitable_event_win.cc
index 597716337be9c92fa264fecd524da9c643d9f301..cbdebbb082cd2a2ab8f223904c0aee26dc3b74a7 100644
--- a/base/synchronization/waitable_event_win.cc
+++ b/base/synchronization/waitable_event_win.cc
@@ -9,6 +9,7 @@
#include <utility>
+#include "base/debug/activity_tracker.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/threading/thread_restrictions.h"
@@ -47,6 +48,9 @@ bool WaitableEvent::IsSignaled() {
}
void WaitableEvent::Wait() {
+ // Record the event that this thread is blocking upon (for hang diagnosis).
+ base::debug::ScopedEventWaitActivity event_activity(this);
+
base::ThreadRestrictions::AssertWaitAllowed();
DWORD result = WaitForSingleObject(handle_.Get(), INFINITE);
// It is most unexpected that this should ever fail. Help consumers learn
@@ -55,6 +59,9 @@ void WaitableEvent::Wait() {
}
bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
+ // Record the event that this thread is blocking upon (for hang diagnosis).
+ base::debug::ScopedEventWaitActivity event_activity(this);
+
base::ThreadRestrictions::AssertWaitAllowed();
DCHECK_GE(max_time, TimeDelta());
// Truncate the timeout to milliseconds. The API specifies that this method
@@ -77,6 +84,11 @@ bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
// static
size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) {
+ DCHECK(count) << "Cannot wait on no events";
+
+ // Record an event (the first) that this thread is blocking upon.
+ base::debug::ScopedEventWaitActivity event_activity(events[0]);
+
base::ThreadRestrictions::AssertWaitAllowed();
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
CHECK_LE(count, static_cast<size_t>(MAXIMUM_WAIT_OBJECTS))
« no previous file with comments | « base/synchronization/waitable_event_posix.cc ('k') | base/threading/platform_thread_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698