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

Side by Side Diff: base/timer/timer.h

Issue 2916693002: DetachFromSequence in Timer::Stop() (Closed)
Patch Set: comment nit Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/timer/timer.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names 5 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names
6 // suggest, OneShotTimer calls you back once after a time delay expires. 6 // suggest, OneShotTimer calls you back once after a time delay expires.
7 // RepeatingTimer on the other hand calls you back periodically with the 7 // RepeatingTimer on the other hand calls you back periodically with the
8 // prescribed time interval. 8 // prescribed time interval.
9 // 9 //
10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of 10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // The desired run time of |user_task_|. The user may update this at any time, 196 // The desired run time of |user_task_|. The user may update this at any time,
197 // even if their previous request has not run yet. If |desired_run_time_| is 197 // even if their previous request has not run yet. If |desired_run_time_| is
198 // greater than |scheduled_run_time_|, a continuation task will be posted to 198 // greater than |scheduled_run_time_|, a continuation task will be posted to
199 // wait for the remaining time. This allows us to reuse the pending task so as 199 // wait for the remaining time. This allows us to reuse the pending task so as
200 // not to flood the delayed queues with orphaned tasks when the user code 200 // not to flood the delayed queues with orphaned tasks when the user code
201 // excessively Stops and Starts the timer. This time can be a "zero" TimeTicks 201 // excessively Stops and Starts the timer. This time can be a "zero" TimeTicks
202 // if the task must be run immediately. 202 // if the task must be run immediately.
203 TimeTicks desired_run_time_; 203 TimeTicks desired_run_time_;
204 204
205 // Timer isn't thread-safe and must only be used on its origin sequence 205 // Timer isn't thread-safe and must only be used on its origin sequence
206 // (sequence on which it was started). 206 // (sequence on which it was started). Once fully Stop()'ed it may be
207 // destroyed or restarted on another sequence.
207 SequenceChecker origin_sequence_checker_; 208 SequenceChecker origin_sequence_checker_;
208 209
209 // Repeating timers automatically post the task again before calling the task 210 // Repeating timers automatically post the task again before calling the task
210 // callback. 211 // callback.
211 const bool is_repeating_; 212 const bool is_repeating_;
212 213
213 // If true, hold on to the |user_task_| closure object for reuse. 214 // If true, hold on to the |user_task_| closure object for reuse.
214 const bool retain_user_task_; 215 const bool retain_user_task_;
215 216
216 // The tick clock used to calculate the run time for scheduled tasks. 217 // The tick clock used to calculate the run time for scheduled tasks.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // to link in MSVC. But clang-plugin does not allow inline definitions of 309 // to link in MSVC. But clang-plugin does not allow inline definitions of
309 // virtual methods, so the inline definition lives in the header file here 310 // virtual methods, so the inline definition lives in the header file here
310 // to satisfy both. 311 // to satisfy both.
311 inline void DelayTimer::Reset() { 312 inline void DelayTimer::Reset() {
312 Timer::Reset(); 313 Timer::Reset();
313 } 314 }
314 315
315 } // namespace base 316 } // namespace base
316 317
317 #endif // BASE_TIMER_TIMER_H_ 318 #endif // BASE_TIMER_TIMER_H_
OLDNEW
« no previous file with comments | « no previous file | base/timer/timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698