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

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/clock/clock.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:
7
7
 
8
8
// Clock provides an interface for dealing with clocks.
9
9
type Clock interface {
10
 
 
11
10
        // Now returns the current clock time.
12
11
        Now() time.Time
13
12
 
17
16
 
18
17
        // AfterFunc waits for the duration to elapse and then calls f in its own goroutine.
19
18
        // It returns a Timer that can be used to cancel the call using its Stop method.
20
 
        AfterFunc(time.Duration, func()) Timer
 
19
        AfterFunc(d time.Duration, f func()) Timer
 
20
 
 
21
        // NewTimer creates a new Timer that will send the current time
 
22
        // on its channel after at least duration d.
 
23
        NewTimer(d time.Duration) Timer
21
24
}
22
25
 
23
26
// Alarm returns a channel that will have the time sent on it at some point
32
35
// A Timer must be created with AfterFunc.
33
36
// This interface follows time.Timer's methods but provides easier mocking.
34
37
type Timer interface {
 
38
        // When the Timer expires, the current time will be sent on the
 
39
        // channel returned from Chan, unless the Timer was created by
 
40
        // AfterFunc.
 
41
        Chan() <-chan time.Time
35
42
 
36
43
        // Reset changes the timer to expire after duration d.
37
44
        // It returns true if the timer had been active, false if