Class: HTTPAccess2::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/reap/vendor/http-access2.rb

Overview

HTTPAccess2::Connection – magage a connection(one request and response to it).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_queue = [], body_queue = []) ⇒ Connection

Returns a new instance of Connection.



794
795
796
797
798
799
# File 'lib/reap/vendor/http-access2.rb', line 794

def initialize(header_queue = [], body_queue = [])
  @headers = header_queue
  @body = body_queue
  @async_thread = nil
  @queue = Queue.new
end

Instance Attribute Details

#async_threadObject

:nodoc:



792
793
794
# File 'lib/reap/vendor/http-access2.rb', line 792

def async_thread
  @async_thread
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


801
802
803
804
805
806
807
808
809
810
811
812
813
# File 'lib/reap/vendor/http-access2.rb', line 801

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

#joinObject



823
824
825
826
827
828
829
# File 'lib/reap/vendor/http-access2.rb', line 823

def join
  unless @async_thread
    false
  else
    @async_thread.join
  end
end

#popObject



815
816
817
# File 'lib/reap/vendor/http-access2.rb', line 815

def pop
  @queue.pop
end

#push(result) ⇒ Object



819
820
821
# File 'lib/reap/vendor/http-access2.rb', line 819

def push(result)
  @queue.push(result)
end