lib/async/http/pool.rb in async-http-0.37.12 vs lib/async/http/pool.rb in async-http-0.37.13

- old
+ new

@@ -46,10 +46,23 @@ @active = 0 @constructor = block end + # The number of allocated resources. + attr :active + + # Whether there are resources which are currently in use. + def busy? + @resources.collect do |_,usage| + return true if usage > 0 + end + + return false + end + + # All allocated resources. attr :resources def empty? @resources.empty? end @@ -92,9 +105,11 @@ def availability_string @resources.collect{|resource,usage| "#{usage}/#{resource.multiplex}#{resource.connected? ? '' : '*'}"}.join(";") end def reuse(resource) + Async.logger.debug(self) {"Reuse #{resource}"} + @resources[resource] -= 1 @available.signal end