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

Side by Side Diff: base/threading/watchdog.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/threading/thread_restrictions.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/threading/watchdog.h" 5 #include "base/threading/watchdog.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 namespace { 14 namespace {
15 15
16 // When the debugger breaks (when we alarm), all the other alarms that are 16 // When the debugger breaks (when we alarm), all the other alarms that are
17 // armed will expire (also alarm). To diminish this effect, we track any 17 // armed will expire (also alarm). To diminish this effect, we track any
18 // delay due to debugger breaks, and we *try* to adjust the effective start 18 // delay due to debugger breaks, and we *try* to adjust the effective start
19 // time of other alarms to step past the debugging break. 19 // time of other alarms to step past the debugging break.
20 // Without this safety net, any alarm will typically trigger a host of follow 20 // Without this safety net, any alarm will typically trigger a host of follow
21 // on alarms from callers that specify old times. 21 // on alarms from callers that specify old times.
22 22
23 // Lock for access of static data... 23 // Lock for access of static data...
24 LazyInstance<Lock, LeakyLazyInstanceTraits<Lock> > g_static_lock( 24 LazyInstance<Lock, LeakyLazyInstanceTraits<Lock> > g_static_lock =
25 LINKER_INITIALIZED); 25 LAZY_INSTANCE_INITIALIZER;
26 26
27 // When did we last alarm and get stuck (for a while) in a debugger? 27 // When did we last alarm and get stuck (for a while) in a debugger?
28 TimeTicks g_last_debugged_alarm_time; 28 TimeTicks g_last_debugged_alarm_time;
29 29
30 // How long did we sit on a break in the debugger? 30 // How long did we sit on a break in the debugger?
31 TimeDelta g_last_debugged_alarm_delay; 31 TimeDelta g_last_debugged_alarm_delay;
32 32
33 } // namespace 33 } // namespace
34 34
35 // Start thread running in a Disarmed state. 35 // Start thread running in a Disarmed state.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 // static 152 // static
153 void Watchdog::ResetStaticData() { 153 void Watchdog::ResetStaticData() {
154 AutoLock lock(*g_static_lock.Pointer()); 154 AutoLock lock(*g_static_lock.Pointer());
155 g_last_debugged_alarm_time = TimeTicks(); 155 g_last_debugged_alarm_time = TimeTicks();
156 g_last_debugged_alarm_delay = TimeDelta(); 156 g_last_debugged_alarm_delay = TimeDelta();
157 } 157 }
158 158
159 } // namespace base 159 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698