Class: Limiter::RateQueue
- Inherits:
-
Object
- Object
- Limiter::RateQueue
- Defined in:
- lib/limiter/rate_queue.rb
Constant Summary collapse
- EPOCH =
Time.at(0)
Instance Method Summary collapse
-
#initialize(size, interval: 60) ⇒ RateQueue
constructor
A new instance of RateQueue.
- #shift ⇒ Object
Constructor Details
Instance Method Details
#shift ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/limiter/rate_queue.rb', line 16 def shift time = nil @mutex.synchronize do time = @ring[@head] sleep_until(time + @interval) @ring[@head] = Time.now @head = (@head + 1) % @size end time end |