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

Unified Diff: base/threading/watchdog.cc

Issue 9173002: Watchdog - Added a JOINABLE state to avoid StartupTimebomb (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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/threading/watchdog.cc
===================================================================
--- base/threading/watchdog.cc (revision 117912)
+++ base/threading/watchdog.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -55,14 +55,29 @@
Watchdog::~Watchdog() {
if (!init_successful_)
return;
+ if (!IsJoinable())
+ Cleanup();
+ condition_variable_.Signal();
+ PlatformThread::Join(handle_);
+}
+
+void Watchdog::Cleanup() {
+ if (!init_successful_)
+ return;
{
AutoLock lock(lock_);
state_ = SHUTDOWN;
}
condition_variable_.Signal();
- PlatformThread::Join(handle_);
}
+bool Watchdog::IsJoinable() {
+ if (!init_successful_)
+ return true;
+ AutoLock lock(lock_);
+ return (state_ == JOINABLE);
+}
+
void Watchdog::Arm() {
ArmAtStartTime(TimeTicks::Now());
}
@@ -105,8 +120,10 @@
AutoLock lock(watchdog_->lock_);
while (DISARMED == watchdog_->state_)
watchdog_->condition_variable_.Wait();
- if (SHUTDOWN == watchdog_->state_)
+ if (SHUTDOWN == watchdog_->state_) {
+ watchdog_->state_ = JOINABLE;
return;
+ }
DCHECK(ARMED == watchdog_->state_);
remaining_duration = watchdog_->duration_ -
(TimeTicks::Now() - watchdog_->start_time_);

Powered by Google App Engine
This is Rietveld 408576698