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
47 48 49 |
# File 'lib/typhoeus/pool.rb', line 47 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/typhoeus/pool.rb', line 32 def self.get @mutex.synchronize do if @pid == Process.pid easies.pop else # Process has forked. Clear all easies to avoid sockets being # shared between processes. @pid = Process.pid easies.clear nil end end || 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.
19 20 21 22 23 24 |
# File 'lib/typhoeus/pool.rb', line 19 def self.release(easy) easy. = "flush" # dump all known cookies to 'cookiejar' easy. = "all" # remove all cookies from memory for this handle 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.
57 58 59 60 61 62 |
# File 'lib/typhoeus/pool.rb', line 57 def self.with_easy(&block) easy = get yield easy ensure release(easy) if easy end |