Module: Falcon::Limiter::Semaphore
- Defined in:
- lib/falcon/limiter/semaphore.rb
Overview
Simple wrapper around Async::Limiter::Queued that provides the interface expected by Falcon while leveraging async-limiter’s implementation.
Class Method Summary collapse
-
.new(limit = 1, **options) ⇒ Object
Create a new limiter with the specified capacity.
Class Method Details
.new(limit = 1, **options) ⇒ Object
Create a new limiter with the specified capacity.
20 21 22 23 24 25 26 |
# File 'lib/falcon/limiter/semaphore.rb', line 20 def self.new(limit = 1, **) # Create priority queue and pre-populate with tokens queue = Async::PriorityQueue.new limit.times{queue.push(true)} return Async::Limiter::Queued.new(queue, **) end |