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 |
| 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) |
| 17 |
| 18 func (t *systemTimer) GetC() (c <-chan time.Time) { |
| 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 |