Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Add detaching an instance from a pool
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Feb 28, 2009
1 parent 94addec commit e2e318c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/extlib/pooling.rb
Expand Up @@ -118,6 +118,10 @@ def release
@__pool.release(self) unless @__pool.nil?
end

def detach
@__pool.delete(self) unless @__pool.nil?
end

class Pool
attr_reader :available
attr_reader :used
Expand Down
7 changes: 7 additions & 0 deletions spec/pooling_spec.rb
Expand Up @@ -153,6 +153,13 @@ def dispose
Extlib::Pooling.scavenger?.should be_false
end

it "should be able to detach an instance from the pool" do
bob = Person.new('Bob')
Person.__pools[['Bob']].size.should == 1
bob.detach
Person.__pools[['Bob']].size.should == 0
end

end

# describe Extlib::Pooling::ResourcePool do
Expand Down

0 comments on commit e2e318c

Please sign in to comment.