lib/picky/pool.rb in picky-4.10.0 vs lib/picky/pool.rb in picky-4.11.0
- old
+ new
@@ -10,11 +10,12 @@
# Installs itself on a few internal classes.
#
# Note: If you need to run two consecutive queries,
# this can't be used.
#
- # TODO Also install calling release_all after each query.
+ # Note: You need to call Picky::Pool.release_all after each query
+ # (or after a few queries).
#
def install
Query::Token.extend self
Query::Tokens.extend self
Query::Combination.extend self
@@ -74,22 +75,24 @@
# Releasing an instance adds it to the free pool.
# (And removes it from the used pool)
#
def release instance
- @__free__ << instance
+ @__free__ << instance
- # Note: This is relatively fast as there are often only
- # few instances in the used pool.
- @__used__.delete instance
+ # Note: This is relatively fast as there are often only
+ # few instances in the used pool.
+ #
+ @__used__.delete instance
end
- # After you have called release all, you can't
+ # After you have called release all, you can't externally
# use any reference that has formerly been obtained
# anymore.
#
def release_all
- @__free__ += @__used__
+ @__used__.each { |used| @__free__ << used } # +0 Array per release_all
+ # @__used__ += @__free__ # +1 Array per release_all
@__used__.clear
end
# How many obtainable objects are there?
#
\ No newline at end of file