lib/aerospike/utils/pool.rb in aerospike-2.1.1 vs lib/aerospike/utils/pool.rb in aerospike-2.2.0
- old
+ new
@@ -12,13 +12,10 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
-require 'thread'
-require 'timeout'
-
module Aerospike
private
class Pool #:nodoc:
@@ -41,24 +38,26 @@
end
end
alias_method :<<, :offer
def poll(create_new=true)
- res = nil
- begin
- res = @pool.pop(true) # non_blocking
- return res
- rescue
- return @create_block.call if @create_block && create_new
- end
+ non_block = true
+ @pool.pop(non_block)
+ rescue
+ @create_block.call() if @create_block && create_new
end
def empty?
@pool.length == 0
end
def length
@pool.length
+ end
+ alias_method :size, :length
+
+ def inspect
+ "#<Aerospike::Pool: size=#{size}>"
end
end
end