OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // The Watchdog class creates a second thread that can Alarm if a specific | 5 // The Watchdog class creates a second thread that can Alarm if a specific |
6 // duration of time passes without proper attention. The duration of time is | 6 // duration of time passes without proper attention. The duration of time is |
7 // specified at construction time. The Watchdog may be used many times by | 7 // specified at construction time. The Watchdog may be used many times by |
8 // simply calling Arm() (to start timing) and Disarm() (to reset the timer). | 8 // simply calling Arm() (to start timing) and Disarm() (to reset the timer). |
9 // The Watchdog is typically used under a debugger, where the stack traces on | 9 // The Watchdog is typically used under a debugger, where the stack traces on |
10 // other threads can be examined if/when the Watchdog alarms. | 10 // other threads can be examined if/when the Watchdog alarms. |
11 | 11 |
12 // Some watchdogs will be enabled or disabled via command line switches. To | 12 // Some watchdogs will be enabled or disabled via command line switches. To |
13 // facilitate such code, an "enabled" argument for the constuctor can be used | 13 // facilitate such code, an "enabled" argument for the constuctor can be used |
14 // to permanently disable the watchdog. Disabled watchdogs don't even spawn | 14 // to permanently disable the watchdog. Disabled watchdogs don't even spawn |
15 // a second thread, and their methods call (Arm() and Disarm()) return very | 15 // a second thread, and their methods call (Arm() and Disarm()) return very |
16 // quickly. | 16 // quickly. |
17 | 17 |
18 #ifndef BASE_THREADING_WATCHDOG_H_ | 18 #ifndef BASE_THREADING_WATCHDOG_H_ |
19 #define BASE_THREADING_WATCHDOG_H_ | 19 #define BASE_THREADING_WATCHDOG_H_ |
20 #pragma once | 20 #pragma once |
21 | 21 |
22 #include <string> | 22 #include <string> |
23 | 23 |
24 #include "base/condition_variable.h" | 24 #include "base/condition_variable.h" |
25 #include "base/lock.h" | 25 #include "base/lock.h" |
26 #include "base/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
27 #include "base/time.h" | 27 #include "base/time.h" |
28 | 28 |
29 namespace base { | 29 namespace base { |
30 | 30 |
31 class Watchdog { | 31 class Watchdog { |
32 public: | 32 public: |
33 // Constructor specifies how long the Watchdog will wait before alarming. | 33 // Constructor specifies how long the Watchdog will wait before alarming. |
34 Watchdog(const base::TimeDelta& duration, | 34 Watchdog(const base::TimeDelta& duration, |
35 const std::string& thread_watched_name, | 35 const std::string& thread_watched_name, |
36 bool enabled); | 36 bool enabled); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 static base::TimeTicks last_debugged_alarm_time_; | 89 static base::TimeTicks last_debugged_alarm_time_; |
90 // How long did we sit on a break in the debugger? | 90 // How long did we sit on a break in the debugger? |
91 static base::TimeDelta last_debugged_alarm_delay_; | 91 static base::TimeDelta last_debugged_alarm_delay_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(Watchdog); | 93 DISALLOW_COPY_AND_ASSIGN(Watchdog); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace base | 96 } // namespace base |
97 | 97 |
98 #endif // BASE_THREADING_WATCHDOG_H_ | 98 #endif // BASE_THREADING_WATCHDOG_H_ |
OLD | NEW |