clock: add NewTimer #242

Merged
merged 1 commit into from Sep 26, 2016

Conversation

Projects
None yet
4 participants
Owner

rogpeppe commented Sep 26, 2016

This allows mock clocks to use timers in the usual way.
This is associated with a companion branch in juju
testing (juju/testing#108) which needs
this as a dependency update.

@rogpeppe rogpeppe referenced this pull request in juju/testing Sep 26, 2016

Merged

implement Clock.NewTimer #108

godocs and LGTM

clock/wall.go
@@ -25,5 +25,17 @@ func (wallClock) After(d time.Duration) <-chan time.Time {
}
func (wallClock) AfterFunc(d time.Duration, f func()) Timer {
@alesstimec

alesstimec Sep 26, 2016

Member

godoc, please

clock/wall.go
+ return wallTimer{time.AfterFunc(d, f)}
+}
+
+func (wallClock) NewTimer(d time.Duration) Timer {
clock/wall.go
+ *time.Timer
+}
+
+func (t wallTimer) Chan() <-chan time.Time {
Owner

rogpeppe commented Sep 26, 2016

$$merge$$

Contributor

jujubot commented Sep 26, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Sep 26, 2016

clock: add NewTimer
Also update the dependencies to use a temporary branch for
juju/testing because of the cyclic dependency on that package.
Owner

rogpeppe commented Sep 26, 2016

$$merge$$

Contributor

jujubot commented Sep 26, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

@jujubot jujubot merged commit 51f3696 into juju:master Sep 26, 2016

jujubot added a commit to juju/testing that referenced this pull request Sep 26, 2016

Merge pull request #108 from rogpeppe/014-clock-newtimer
implement Clock.NewTimer

Also fix some issues with the current implementation - it's allowable
to call Reset after a timer has expired to make the timer fire again,
which wouldn't work with the previous implementation.

Note that this will require a dependency update to use juju/utils#242.

(Review request: http://reviews.vapour.ws/r/5372/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment