File tree Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -91,25 +91,24 @@ func (t *Timer) Stop() error {
91
91
}
92
92
93
93
// WaitTill waits until the internal timer duration is reached.
94
- func (t * Timer ) WaitTill (duration time.Duration ) error {
94
+ func (t * Timer ) WaitTill (duration time.Duration ) {
95
95
if ! t .running {
96
96
select {
97
97
case t .continueChan <- struct {}{}:
98
98
case <- time .After (1 * time .Second ):
99
- return nil
99
+ return
100
100
}
101
101
}
102
102
sleepTime := duration - t .Elapsed ()
103
103
if sleepTime > 0 {
104
104
t .SleepConsumer (sleepTime )
105
105
}
106
- return nil
106
+ return
107
107
}
108
108
109
109
// WaitTillNextFullSecond waits until the internal timer has reached the next full second
110
- func (t * Timer ) WaitTillNextFullSecond () error {
110
+ func (t * Timer ) WaitTillNextFullSecond () {
111
111
elapsed := t .Elapsed ()
112
112
nextDuration := elapsed .Truncate (time .Second ) + time .Second
113
113
t .WaitTill (nextDuration )
114
- return nil
115
114
}
Original file line number Diff line number Diff line change @@ -56,20 +56,14 @@ func TestTimerWaitTill(t *testing.T) {
56
56
t .Error (err )
57
57
}
58
58
* curTime = curTime .Add (2 * time .Second )
59
- err = timer .WaitTill (5 * time .Second )
60
- if err != nil {
61
- t .Error (err )
62
- }
59
+ timer .WaitTill (5 * time .Second )
63
60
if * sleepDuration != 3 * time .Second {
64
61
t .Errorf ("Expected a sleep duration of 3s, but was %v" , * sleepDuration )
65
62
}
66
63
67
64
* sleepDuration = 0
68
65
* curTime = curTime .Add (100 * time .Millisecond )
69
- err = timer .WaitTillNextFullSecond ()
70
- if err != nil {
71
- t .Error (err )
72
- }
66
+ timer .WaitTillNextFullSecond ()
73
67
if * sleepDuration != 900 * time .Millisecond {
74
68
t .Errorf ("Expected a sleep duration of 900ms, but was %v" , * sleepDuration )
75
69
}
You can’t perform that action at this time.
0 commit comments