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.
745 746 747 748 749 750 |
# File 'lib/httpclient.rb', line 745 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:
743 744 745 |
# File 'lib/httpclient.rb', line 743 def async_thread @async_thread end |
Instance Method Details
#finished? ⇒ Boolean
752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/httpclient.rb', line 752 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
774 775 776 777 778 779 780 |
# File 'lib/httpclient.rb', line 774 def join unless @async_thread false else @async_thread.join end end |
#pop ⇒ Object
766 767 768 |
# File 'lib/httpclient.rb', line 766 def pop @queue.pop end |
#push(result) ⇒ Object
770 771 772 |
# File 'lib/httpclient.rb', line 770 def push(result) @queue.push(result) end |