OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package clock | 5 package clock |
6 | 6 |
7 import ( | 7 import ( |
8 "time" | 8 "time" |
9 ) | 9 ) |
10 | 10 |
11 // Timer is a wrapper around the time.Timer structure. | 11 // Timer is a wrapper around the time.Timer structure. |
12 // | 12 // |
13 // A Timer is instantiated from a Clock instance and started via its Reset() | 13 // A Timer is instantiated from a Clock instance and started via its Reset() |
14 // method. | 14 // method. |
15 type Timer interface { | 15 type Timer interface { |
16 » // GetC returns the underlying timer's channel, or nil if the timer is n o | 16 » // GetC returns the underlying timer's channel. |
iannucci
2016/02/10 22:30:28
doc behavior with Reset and Stop
dnj (Google)
2016/02/11 01:26:55
Done.
| |
17 » // running. | 17 » GetC() <-chan TimerResult |
18 » GetC() <-chan time.Time | |
19 | 18 |
20 // Reset configures the timer to expire after a specified duration. | 19 // Reset configures the timer to expire after a specified duration. |
21 // | 20 // |
22 // If the timer is already running, its previous state will be cleared a nd | 21 // If the timer is already running, its previous state will be cleared a nd |
23 // this method will return true. | 22 // this method will return true. |
24 Reset(d time.Duration) bool | 23 Reset(d time.Duration) bool |
25 | 24 |
26 // Stop clears any timer tasking, rendering it inactive. | 25 // Stop clears any timer tasking, rendering it inactive. |
27 // | 26 // |
28 // Stop may be called on an inactive timer, in which case nothing will h appen | 27 // Stop may be called on an inactive timer, in which case nothing will h appen |
29 // If the timer is active, it will be stopped and this method will retur n true. | 28 // If the timer is active, it will be stopped and this method will retur n true. |
30 Stop() bool | 29 Stop() bool |
31 } | 30 } |
31 | |
32 // TimerResult is the result fo a timer operation. | |
iannucci
2016/02/10 22:30:28
fo'
dnj (Google)
2016/02/11 01:26:55
Done.
| |
33 // | |
34 // If the timer operation completed successfully, the embedded time.Time will be | |
35 // set to the time when the timer triggered. If the timer was prematurely | |
36 // terminated, Err will be non-nil. | |
iannucci
2016/02/10 22:30:28
time will be the time when the result was generate
dnj (Google)
2016/02/11 01:26:55
Done.
| |
37 type TimerResult struct { | |
38 time.Time | |
39 | |
40 // Err, if not nil, indicates that After did not finish naturally and co ntains | |
41 // the reason why. | |
42 Err error | |
43 } | |
OLD | NEW |