Typhoeus::Pool

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

clear() click to toggle source
# File lib/typhoeus/pool.rb, line 35
def clear
  @mutex.synchronize { easies.clear }
end
get() click to toggle source

Return an easy from the pool.

@example Return easy.

hydra.get_easy

@return [ Ethon::Easy ] The easy.

# File lib/typhoeus/pool.rb, line 31
def get
  @mutex.synchronize { easies.pop } || Ethon::Easy.new
end
release(easy) click to toggle source

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

@example Release easy.

hydra.release_easy(easy)
# File lib/typhoeus/pool.rb, line 20
def release(easy)
  easy.reset
  @mutex.synchronize { easies << easy }
end
with_easy(&block) click to toggle source
# File lib/typhoeus/pool.rb, line 39
def with_easy(&block)
  easy = get
  yield easy
ensure
  release(easy) if easy
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.