This class encapsulates an asynchronous response that will block the caller until the response is available.
The PredictionIO::AsyncRequest instance that created the current PredictionIO::AsyncResponse instance.
Create the response by saving the request, and optionally the Net::HTTPResponse object.
# File lib/predictionio/async_response.rb, line 11 def initialize(request, response = nil) @request = request @response = Queue.new set(response) if response end
Get the Net::HTTPResponse instance. This will block if the response is not yet available.
# File lib/predictionio/async_response.rb, line 24 def get @response.pop end
Save a Net::HTTPResponse instance to the current instance. This will unblock any caller that called get.
# File lib/predictionio/async_response.rb, line 19 def set(response) @response.push(response) end