OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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 systemclock | |
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 } | |
iannucci
2015/06/02 22:19:03
var _ clock.Timer = (*systemTimer)(nil) // since
dnj
2015/06/03 00:25:28
Done.
| |
15 | |
16 // Implements Timer. | |
17 func (t *systemTimer) GetC() (c <-chan time.Time) { | |
18 if t.T != nil { | |
19 c = t.T.C | |
20 } | |
21 return | |
22 } | |
23 | |
24 // Implements Timer. | |
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 // Implements Timer. | |
34 func (t *systemTimer) Stop() bool { | |
35 if t.T == nil { | |
36 return false | |
37 } | |
38 return t.T.Stop() | |
39 } | |
OLD | NEW |