juju / ratelimit

Efficient token-bucket-based rate limiter package.
Other
2.78k stars 310 forks source link

Can you remove Lock #35

Open maczam opened 4 years ago

maczam commented 4 years ago

In the process of using ratelimit,there's a lock in the source code . can you replace it with atomic?

func (tb *Bucket) TakeAvailable(count int64) int64 { tb.mu.Lock() defer tb.mu.Unlock() return tb.takeAvailable(tb.clock.Now(), count) }

maczam commented 4 years ago

Similar https://github.com/uber-go/ratelimit https://github.com/maczam/ymratelimit