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.
Class Method Summary collapse
-
.clear ⇒ Object
private
Clear the pool.
-
.get ⇒ Ethon::Easy
private
Return an easy from the pool.
-
.release(easy) ⇒ Object
private
Releases easy into the pool.
-
.with_easy(&block) ⇒ Object
private
Use yielded easy, will be released automatically afterwards.
Class Method Details
.clear ⇒ 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.
Clear the pool
34 35 36 |
# File 'lib/typhoeus/pool.rb', line 34 def self.clear @mutex.synchronize { easies.clear } end |
.get ⇒ 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 an easy from the pool.
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.
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.
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 |