Sha256: d0f839c8c6fd7dce65e5513dda18fac5ecd2cd08133d206753d6bab906d24b26
Contents?: true
Size: 636 Bytes
Versions: 5
Compression:
Stored size: 636 Bytes
Contents
# "Clone" of normal ConnectionPool but tweaked for round-robin class Fwd::Pool include Enumerable class IdleStack < ConnectionPool::TimedStack def unshift(obj) @mutex.synchronize do @que.unshift obj @resource.broadcast end end end def initialize(items) @idle = IdleStack.new(0) {} @size = items.size @key = :"io-proxy-pool-#{@idle.object_id}" items.each do |item| @idle.push(item) end end def each(&block) @size.times { checkout(&block) } end def checkout conn = @idle.pop(30) yield conn ensure @idle.unshift(conn) if conn end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
fwd-0.4.0 | lib/fwd/pool.rb |
fwd-0.3.3 | lib/fwd/pool.rb |
fwd-0.3.2 | lib/fwd/pool.rb |
fwd-0.3.1 | lib/fwd/pool.rb |
fwd-0.3.0 | lib/fwd/pool.rb |