Skip to content

Commit

Permalink
issue fix for timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangkun committed Dec 4, 2021
1 parent 498a9a6 commit b3d6d26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
6 changes: 1 addition & 5 deletions hookq/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,10 @@ func (c *Consumer) start() {
c.process()
if timer == nil {
timer = time.NewTimer(c.tick)
} else {
if !timer.Stop() {
<-timer.C
}
timer.Reset(c.tick)
}
select {
case <-timer.C:
timer.Reset(c.tick)
case <-c.stopChan:
c.submitWhenExit()
if !timer.Stop() {
Expand Down
1 change: 1 addition & 0 deletions hookq/example/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func consumerMsg(c *cli.Context) error {
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
select {
case <-signalChan:
log.Println("received.exit.ctrl-c")
consumer.Stop()
consumer.Wait()
log.Println("consumer.exit.by.signal")
Expand Down

0 comments on commit b3d6d26

Please sign in to comment.