Module: Typhoeus::Pool Private
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.
Instance Method Summary collapse
- #clear ⇒ Object private
-
#get ⇒ Ethon::Easy
private
Return an easy from the pool.
-
#release(easy) ⇒ Object
private
Releases easy into the pool.
- #with_easy(&block) ⇒ Object private
Instance 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.
35 36 37 |
# File 'lib/typhoeus/pool.rb', line 35 def 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.
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.
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.
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 |