Skip to content

Commit

Permalink
Merge pull request #2 from pinealctx/dev
Browse files Browse the repository at this point in the history
issue fix for timer.
  • Loading branch information
xpineal authored Dec 4, 2021
2 parents d706dd9 + b3d6d26 commit 8c676f7
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 8c676f7

Please sign in to comment.