module Typhoeus::Hydra::EasyPool

The easy pool stores already initialized easy handles for future use. This is useful because creating them is quite expensive.

@api private

Public Instance Methods

easy_pool() click to toggle source

Return the easy pool.

@example Return easy pool.

hydra.easy_pool

@return [ Array<Ethon::Easy> ] The easy pool.

# File lib/typhoeus/hydra/easy_pool.rb, line 17
def easy_pool
  @easy_pool ||= []
end
get_easy() click to toggle source

Return an easy from pool.

@example Return easy.

hydra.get_easy

@return [ Ethon::Easy ] The easy.

# File lib/typhoeus/hydra/easy_pool.rb, line 37
def get_easy
  easy_pool.pop || Ethon::Easy.new
end
release_easy(easy) click to toggle source

Releases easy into pool. The easy handle is resetted before it gets back in.

@example Release easy.

hydra.release_easy(easy)
# File lib/typhoeus/hydra/easy_pool.rb, line 26
def release_easy(easy)
  easy.reset
  easy_pool << easy
end