Sha256: 654b3f673b827e46d1fb14712bbc1c08b7a52d6b77945182d80f5a838181e8ba
Contents?: true
Size: 775 Bytes
Versions: 4
Compression:
Stored size: 775 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 unpause @paused = false end def paused? @paused end def block @block = true end def unblock @block = false end def blocking? @block end end end
Version data entries
4 entries across 4 versions & 1 rubygems