~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/clock/wall.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
// WallClock exposes wall-clock time via the Clock interface.
11
11
var WallClock wallClock
12
12
 
 
13
// ensure that WallClock does actually implement the Clock interface.
 
14
var _ Clock = WallClock
 
15
 
13
16
// WallClock exposes wall-clock time as returned by time.Now.
14
17
type wallClock struct{}
15
18
 
18
21
        return time.Now()
19
22
}
20
23
 
21
 
// Alarm returns a channel that will send a value at some point after
22
 
// the supplied time.
 
24
// After implements Clock.After.
23
25
func (wallClock) After(d time.Duration) <-chan time.Time {
24
26
        return time.After(d)
25
27
}
26
28
 
 
29
// AfterFunc implements Clock.AfterFunc.
27
30
func (wallClock) AfterFunc(d time.Duration, f func()) Timer {
28
 
        return time.AfterFunc(d, f)
 
31
        return wallTimer{time.AfterFunc(d, f)}
 
32
}
 
33
 
 
34
// NewTimer implements Clock.NewTimer.
 
35
func (wallClock) NewTimer(d time.Duration) Timer {
 
36
        return wallTimer{time.NewTimer(d)}
 
37
}
 
38
 
 
39
// wallTimer implements the Timer interface.
 
40
type wallTimer struct {
 
41
        *time.Timer
 
42
}
 
43
 
 
44
// Chan implements Timer.Chan.
 
45
func (t wallTimer) Chan() <-chan time.Time {
 
46
        return t.C
29
47
}