class Async::Pool::Controller
def prune(retain = 0)
-
retain(Integer) -- the minimum number of resources to retain.
def prune(retain = 0) unused = [] @resources.each do |resource, usage| if usage.zero? unused << resource end end unused.each do |resource| if block_given? yield resource else retire(resource) end break if @resources.size <= retain end # Update availability list: @available.clear @resources.each do |resource, usage| if usage < resource.concurrency and resource.reusable? @available << resource end end return unused.size end