Module: Typhoeus::Pool Private

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 expensive.

Since:

  • 0.5.0

Class Method Summary collapse

Class 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.

Clear the pool

Since:

  • 0.5.0



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

def self.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.

Typhoeus::Pool.get

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



29
30
31
# File 'lib/typhoeus/pool.rb', line 29

def self.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.

Typhoeus::Pool.release(easy)

Since:

  • 0.5.0



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

def self.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.

Use yielded easy, will be released automatically afterwards.

Examples:

Use easy.

Typhoeus::Pool.with_easy do |easy|
  # use easy
end

Since:

  • 0.5.0



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

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