Skip to content

Commit

Permalink
Confirm that resource usage is still 0 before retiring. (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
zarqman authored Apr 22, 2024
1 parent ee098ef commit ed9050c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thomas Morgan <[email protected]>
10 changes: 6 additions & 4 deletions lib/async/pool/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ def prune(retain = 0)

# It's okay for this to context switch:
unused.each do |resource|
if block_given?
yield resource
else
retire(resource)
if usage = @resources[resource] and usage.zero?
if block_given?
yield resource
else
retire(resource)
end
end

break if @resources.size <= retain
Expand Down

0 comments on commit ed9050c

Please sign in to comment.