Change quota version to uint32 instead on uint64 (#1517)
This commit is contained in:
@ -126,7 +126,7 @@ type quotaPool struct {
|
|||||||
c chan int
|
c chan int
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
version uint64
|
version uint32
|
||||||
quota int
|
quota int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,17 +183,17 @@ func (qb *quotaPool) addAndUpdate(v int) {
|
|||||||
// compareAndExecute is processing, this function doesn't
|
// compareAndExecute is processing, this function doesn't
|
||||||
// get executed partially (quota gets updated but the version
|
// get executed partially (quota gets updated but the version
|
||||||
// doesn't).
|
// doesn't).
|
||||||
atomic.AddUint64(&(qb.version), 1)
|
atomic.AddUint32(&(qb.version), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qb *quotaPool) acquireWithVersion() (<-chan int, uint64) {
|
func (qb *quotaPool) acquireWithVersion() (<-chan int, uint32) {
|
||||||
return qb.c, atomic.LoadUint64(&(qb.version))
|
return qb.c, atomic.LoadUint32(&(qb.version))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qb *quotaPool) compareAndExecute(version uint64, success, failure func()) bool {
|
func (qb *quotaPool) compareAndExecute(version uint32, success, failure func()) bool {
|
||||||
qb.mu.Lock()
|
qb.mu.Lock()
|
||||||
defer qb.mu.Unlock()
|
defer qb.mu.Unlock()
|
||||||
if version == atomic.LoadUint64(&(qb.version)) {
|
if version == atomic.LoadUint32(&(qb.version)) {
|
||||||
success()
|
success()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user