Class: HTTPAccess2::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rss-client/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.



1227
1228
1229
1230
1231
1232
# File 'lib/rss-client/http-access2.rb', line 1227

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:



1225
1226
1227
# File 'lib/rss-client/http-access2.rb', line 1225

def async_thread
  @async_thread
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/rss-client/http-access2.rb', line 1234

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



1256
1257
1258
1259
1260
1261
1262
# File 'lib/rss-client/http-access2.rb', line 1256

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

#popObject



1248
1249
1250
# File 'lib/rss-client/http-access2.rb', line 1248

def pop
  @queue.pop
end

#push(result) ⇒ Object



1252
1253
1254
# File 'lib/rss-client/http-access2.rb', line 1252

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