Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: go/src/infra/libs/clock/systemclock.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added coverage files. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/libs/clock/context.go ('k') | go/src/infra/libs/clock/systemtimer.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/clock/context.go ('k') | go/src/infra/libs/clock/systemtimer.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698