Skip to content

Commit

Permalink
nsqd: reduce ReadyCount update frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Dec 24, 2019
1 parent f6bc2bf commit 368af1a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nsqd/client_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ func (c *clientV2) IsReadyForMessages() bool {
}

func (c *clientV2) SetReadyCount(count int64) {
atomic.StoreInt64(&c.ReadyCount, count)
c.tryUpdateReadyState()
oldCount := atomic.SwapInt64(&c.ReadyCount, count)

if oldCount != count {
c.tryUpdateReadyState()
}
}

func (c *clientV2) tryUpdateReadyState() {
Expand Down

0 comments on commit 368af1a

Please sign in to comment.