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

Unified Diff: gpu/ipc/service/gpu_watchdog_thread.cc

Issue 2389633003: Throttle GpuWatchdogThread task posting (Closed)
Patch Set: Created 4 years, 2 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 | « gpu/ipc/service/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/ipc/service/gpu_watchdog_thread.cc
diff --git a/gpu/ipc/service/gpu_watchdog_thread.cc b/gpu/ipc/service/gpu_watchdog_thread.cc
index 4c8c04c9f38118594eddc21106674aecc468428b..5d7e3bb18fc465a6a2f377c1387360f32b591690 100644
--- a/gpu/ipc/service/gpu_watchdog_thread.cc
+++ b/gpu/ipc/service/gpu_watchdog_thread.cc
@@ -66,6 +66,8 @@ GpuWatchdogThread::GpuWatchdogThread()
host_tty_(-1),
#endif
weak_factory_(this) {
+ base::subtle::NoBarrier_Store(&awaiting_acknowledge_, false);
+
#if defined(OS_WIN)
// GetCurrentThread returns a pseudo-handle that cannot be used by one thread
// to identify another. DuplicateHandle creates a "real" handle that can be
@@ -100,11 +102,12 @@ void GpuWatchdogThread::PostAcknowledge() {
}
void GpuWatchdogThread::CheckArmed() {
- // Acknowledge the watchdog if it has armed itself. The watchdog will not
- // change its armed state until it is acknowledged.
- if (armed()) {
+ // If the watchdog is |awaiting_acknowledge_|, reset this variable to false
+ // and post an acknowledge task now. No barrier is needed as
+ // |awaiting_acknowledge_| is only ever read from this thread.
+ if (base::subtle::NoBarrier_CompareAndSwap(&awaiting_acknowledge_, true,
+ false))
PostAcknowledge();
- }
}
void GpuWatchdogThread::Init() {
@@ -209,11 +212,14 @@ void GpuWatchdogThread::OnCheck(bool after_suspend) {
if (armed_ || suspended_)
return;
- // Must set armed before posting the task. This task might be the only task
- // that will activate the TaskObserver on the watched thread and it must not
- // miss the false -> true transition.
armed_ = true;
+ // Must set |awaiting_acknowledge_| before posting the task. This task might
+ // be the only task that will activate the TaskObserver on the watched thread
+ // and it must not miss the false -> true transition. No barrier is needed
+ // here, as the PostTask which follows contains a barrier.
+ base::subtle::NoBarrier_Store(&awaiting_acknowledge_, true);
+
#if defined(OS_WIN)
arm_cpu_time_ = GetWatchedThreadTime();
« no previous file with comments | « gpu/ipc/service/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698