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



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

def clear
  easies.clear
end

#easiesArray<Ethon::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 the easy pool.

Examples:

Return easy pool.

hydra.easy_pool

Returns:

  • (Array<Ethon::Easy>)

    The easy pool.

Since:

  • 0.5.0



17
18
19
# File 'lib/typhoeus/pool.rb', line 17

def easies
  @easies ||= []
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 pool.

Examples:

Return easy.

hydra.get_easy

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



37
38
39
# File 'lib/typhoeus/pool.rb', line 37

def get
  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 pool. The easy handle is resetted before it gets back in.

Examples:

Release easy.

hydra.release_easy(easy)

Since:

  • 0.5.0



26
27
28
29
# File 'lib/typhoeus/pool.rb', line 26

def release(easy)
  easy.reset
  easies << easy
end

#with_easy {|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.

Yields:

  • (easy)

Since:

  • 0.5.0



45
46
47
48
49
# File 'lib/typhoeus/pool.rb', line 45

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