| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 // Implementation of Clock that uses Go's standard library. | |
| 12 type systemClock struct{} | |
| 13 | |
| 14 // System clock instance. | |
| 15 var systemClockInstance systemClock | |
| 16 | |
| 17 var _ Clock = systemClock{} | |
| 18 | |
| 19 // GetSystemClock returns an instance of a Clock whose method calls directly use | |
| 20 // Go's "time" library. | |
| 21 func GetSystemClock() Clock { | |
| 22 return systemClockInstance | |
| 23 } | |
| 24 | |
| 25 func (systemClock) Now() time.Time { | |
| 26 return time.Now() | |
| 27 } | |
| 28 | |
| 29 func (systemClock) Sleep(d time.Duration) { | |
| 30 time.Sleep(d) | |
| 31 } | |
| 32 | |
| 33 func (systemClock) NewTimer() Timer { | |
| 34 return new(systemTimer) | |
| 35 } | |
| 36 | |
| 37 func (systemClock) After(d time.Duration) <-chan time.Time { | |
| 38 return time.After(d) | |
| 39 } | |
| OLD | NEW |