Sha256: 8921d19e6405e77f4bb144cf76b5826a8aba239b8e918b50bccac1b4dca50b4c
Contents?: true
Size: 915 Bytes
Versions: 5
Compression:
Stored size: 915 Bytes
Contents
module Sidekiq::LimitFetch::Local class Semaphore attr_reader :limit, :busy, :unblocked 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 block_except(*queues) raise ArgumentError if queues.empty? @unblocked = queues @block = true end def unblock @block = false end def blocking? @block end end end
Version data entries
5 entries across 5 versions & 1 rubygems