class PredictionIO::AsyncResponse
This class encapsulates an asynchronous response that will block the caller until the response is available.
Attributes
request[R]
The PredictionIO::AsyncRequest
instance that created the current PredictionIO::AsyncResponse
instance.
Public Class Methods
new(request, response = nil)
click to toggle source
Create the response by saving the request, and optionally the Net::HTTPResponse object.
# File lib/predictionio/async_response.rb, line 26 def initialize(request, response = nil) @request = request @response = Queue.new set(response) if response end
Public Instance Methods
get()
click to toggle source
Get the Net::HTTPResponse instance. This will block if the response is not yet available.
# File lib/predictionio/async_response.rb, line 39 def get @response.pop end
set(response)
click to toggle source
Save a Net::HTTPResponse instance to the current instance. This will unblock any caller that called get
.
# File lib/predictionio/async_response.rb, line 34 def set(response) @response.push(response) end