A quick-and-dirty implementation of RPS limiter. Self-contained, no dependencies on any third-parties. Should not depend on platform, however, was tested only with Visual Studio.
Append the time stamp of the incoming request to the priority queue.
If the queue is full, try replace the oldest request. If delta in timestamps < 1 second, decline the current request.
Pros: no extra thread; no external timer/tick needed.
Cons; need to keep the potentially large array of Max_RPS time stamps.
See the constant 'workaround' used by HitQueue implementation.
It seems that using the sliding window of a size that slightly exceeds 1 second should be enough to ensure no false positives (requests that should be rejected, but are accepted).
However, one of the tests (the commented one) keeps failing when I change the value of the parameter.