OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package clock | |
iannucci
2015/06/03 17:37:20
systemtimer
dnj
2015/06/03 18:21:27
(In "clock" package now).
| |
6 | |
7 import ( | |
8 "time" | |
9 ) | |
10 | |
11 // A Timer implementation that uses time.Timer. | |
12 type systemTimer struct { | |
13 T *time.Timer // The underlying timer. Starts as nil, is initialized on Reset. | |
14 } | |
15 | |
16 var _ Timer = (*systemTimer)(nil) | |
iannucci
2015/06/03 17:37:20
where does Timer come from? Should this be clock.T
dnj
2015/06/03 18:21:27
(In "clock" package now).
| |
17 | |
18 func (t *systemTimer) GetC() (c <-chan time.Time) { | |
iannucci
2015/06/03 17:37:20
C()
see https://golang.org/doc/effective_go.html#
dnj
2015/06/03 18:21:27
(In "clock" package now).
| |
19 if t.T != nil { | |
20 c = t.T.C | |
21 } | |
22 return | |
23 } | |
24 | |
25 func (t *systemTimer) Reset(d time.Duration) bool { | |
26 if t.T == nil { | |
27 t.T = time.NewTimer(d) | |
28 return false | |
29 } | |
30 return t.T.Reset(d) | |
31 } | |
32 | |
33 func (t *systemTimer) Stop() bool { | |
34 if t.T == nil { | |
35 return false | |
36 } | |
37 return t.T.Stop() | |
38 } | |
OLD | NEW |