Class: HTTPClient::Connection
- Inherits:
-
Object
- Object
- HTTPClient::Connection
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::Connection – magage a connection(one request and response to it).
Instance Attribute Summary collapse
-
#async_thread ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #finished? ⇒ Boolean
-
#initialize(header_queue = [], body_queue = []) ⇒ Connection
constructor
A new instance of Connection.
- #join ⇒ Object
- #pop ⇒ Object
- #push(result) ⇒ Object
Constructor Details
#initialize(header_queue = [], body_queue = []) ⇒ Connection
Returns a new instance of Connection.
829 830 831 832 833 834 |
# File 'lib/httpclient.rb', line 829 def initialize(header_queue = [], body_queue = []) @headers = header_queue @body = body_queue @async_thread = nil @queue = Queue.new end |
Instance Attribute Details
#async_thread ⇒ Object
:nodoc:
827 828 829 |
# File 'lib/httpclient.rb', line 827 def async_thread @async_thread end |
Instance Method Details
#finished? ⇒ Boolean
836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/httpclient.rb', line 836 def finished? if !@async_thread # Not in async mode. true elsif @async_thread.alive? # Working... false else # Async thread have been finished. @async_thread.join true end end |
#join ⇒ Object
858 859 860 861 862 863 864 |
# File 'lib/httpclient.rb', line 858 def join unless @async_thread false else @async_thread.join end end |
#pop ⇒ Object
850 851 852 |
# File 'lib/httpclient.rb', line 850 def pop @queue.pop end |
#push(result) ⇒ Object
854 855 856 |
# File 'lib/httpclient.rb', line 854 def push(result) @queue.push(result) end |