rigtorp/TokenBucket

Unnecessary `atomic`s for member variables

Closed this issue · 1 comments

As it stands, there's no need for timePerToken_ and timePerBurst_ to be declared as std::atomic<uint64_t> because there are no concurrent modifications to either variable. The consume function modifies time_, but only reads from the other two aforementioned variables. Can they become simply uint64_t?

I'm doing relaxed loads from them, so it has no performance impact. But it guarantees you to not get a totally screwy result if you are racing with the assignment operator.