Skip to content

Commit

Permalink
Make this example code to make more sense
Browse files Browse the repository at this point in the history
I'd suggest to implement worker() implementation to actually do something useful rather than hang on waiting for stop signal to read ;)
  • Loading branch information
jswierad authored and sevlyar committed Jun 1, 2018
1 parent 45a2ba1 commit f9261e7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/cmd/gd-signal-handling/signal-handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ var (
)

func worker() {
LOOP:
for {
time.Sleep(time.Second)
if _, ok := <-stop; ok {
break
time.Sleep(time.Second) // this is work to be done by worker.
select {
case <- stop:
break LOOP
default:
}
}
done <- struct{}{}
Expand Down

0 comments on commit f9261e7

Please sign in to comment.