lytefast / gcra-rs

Basic rust GCRA implementation
MIT License
7 stars 1 forks source link

RateLimiter mut self? #6

Closed anlumo closed 1 month ago

anlumo commented 1 month ago

Why does RateLimiter::check_at take &mut self? Nothing in that function looks like it needs a mutable reference to self.

It only accesses the dashmap, and none of dashmap's functions need a mutable reference (that's the entire point of dashmap).

With the requirement for a mutable reference to self, the promise from the README "Implements Send + Sync so can be used asynchronously." is kinda moot, since the only way to share a value which can be mutated is through Mutex or similar methods.

lytefast commented 1 month ago

you are right. The RateLimiter functions don't need to take &mut self references and can rely on the dashmap's concurrent access properties

lytefast commented 1 month ago

@anlumo Thanks for the report. 0.5.0 release should have this fix.