Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runner: reduce for+select to for range in runner.Loop #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions spread/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,14 @@ func (r *Runner) loop() (err error) {
}
}

for {
select {
case <-r.done:
r.alive--
if r.alive > 0 {
debugf("Worker terminated. %d still alive.", r.alive)
continue
}
debugf("Worker terminated.")
return nil
for range r.done {
r.alive--
if r.alive > 0 {
debugf("Worker terminated. %d still alive.", r.alive)
continue
}
debugf("Worker terminated.")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, looks like this is not ready. Current go complains:

./runner.go:246:1: missing return at end of function

we could of course just move the reutrn down but i would feel better I think if we had a a unit test here, given the function I'm not sure that is easy to do though :/

}
}

Expand Down