Module: Typhoeus::Pool Private

Extended by:
Pool
Included in:
Pool
Defined in:
lib/typhoeus/pool.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.5.0



35
36
37
# File 'lib/typhoeus/pool.rb', line 35

def clear
  @mutex.synchronize { easies.clear }
end

#getEthon::Easy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return an easy from the pool.

Examples:

Return easy.

hydra.get_easy

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



31
32
33
# File 'lib/typhoeus/pool.rb', line 31

def get
  @mutex.synchronize { easies.pop } || Ethon::Easy.new
end

#release(easy) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Examples:

Release easy.

hydra.release_easy(easy)

Since:

  • 0.5.0



20
21
22
23
# File 'lib/typhoeus/pool.rb', line 20

def release(easy)
  easy.reset
  @mutex.synchronize { easies << easy }
end

#with_easy(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.5.0



39
40
41
42
43
44
# File 'lib/typhoeus/pool.rb', line 39

def with_easy(&block)
  easy = get
  yield easy
ensure
  release(easy) if easy
end