Replace calls to time.After with time.NewTimer for explicit stopping

This commit is contained in:
Daniel Smith
2015-05-04 14:29:33 -07:00
parent 838b59cb4d
commit 16a6fb8ef7
6 changed files with 48 additions and 18 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:
}
}
}