Merge pull request #7737 from lavalamp/fixTimeAfter

Reduce usage of time.After
This commit is contained in:
Wojciech Tyczynski
2015-05-05 09:28:07 +02:00
7 changed files with 49 additions and 19 deletions

View File

@@ -29,6 +29,8 @@ import (
)
func (m *Master) serviceWriterLoop(stop chan struct{}) {
t := time.NewTicker(10 * time.Second)
defer t.Stop()
for {
// Update service & endpoint records.
// TODO: when it becomes possible to change this stuff,
@@ -49,12 +51,14 @@ func (m *Master) serviceWriterLoop(stop chan struct{}) {
select {
case <-stop:
return
case <-time.After(10 * time.Second):
case <-t.C:
}
}
}
func (m *Master) roServiceWriterLoop(stop chan struct{}) {
t := time.NewTicker(10 * time.Second)
defer t.Stop()
for {
// Update service & endpoint records.
// TODO: when it becomes possible to change this stuff,
@@ -74,7 +78,7 @@ func (m *Master) roServiceWriterLoop(stop chan struct{}) {
select {
case <-stop:
return
case <-time.After(10 * time.Second):
case <-t.C:
}
}
}