Sha256: e0a93811bea10c7ada60415d59ec64f6e4e25178f9c1f7b147481e743c9f08b5
Contents?: true
Size: 384 Bytes
Versions: 2
Compression:
Stored size: 384 Bytes
Contents
class Sidekiq::LimitFetch::Semaphore attr_reader :limit, :busy def initialize @lock = Mutex.new @busy = 0 end def limit=(value) @lock.synchronize do @limit = value end end def acquire @lock.synchronize do @busy += 1 if not @limit or @limit > @busy end end def release @lock.synchronize do @busy -= 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-limit_fetch-0.4 | lib/sidekiq/limit_fetch/semaphore.rb |
sidekiq-limit_fetch-0.3 | lib/sidekiq/limit_fetch/semaphore.rb |