Sha256: 9984a4b28b903ff6b7027fed36ea8b808263ac96aaaf04e80af2fd8ffef9bb9c
Contents?: true
Size: 608 Bytes
Versions: 2
Compression:
Stored size: 608 Bytes
Contents
module Sidekiq::LimitFetch::Local class Semaphore attr_reader :limit, :busy def initialize(name) @name = name @lock = Mutex.new @busy = 0 @paused = false end def limit=(value) @lock.synchronize do @limit = value end end def acquire return if @paused @lock.synchronize do @busy += 1 if not @limit or @limit > @busy end end def release @lock.synchronize do @busy -= 1 end end def pause @paused = true end def continue @paused = false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-limit_fetch-0.7 | lib/sidekiq/limit_fetch/local/semaphore.rb |
sidekiq-limit_fetch-0.6 | lib/sidekiq/limit_fetch/local/semaphore.rb |