Sha256: 70613cad20e39a1888b613eea5ac11427026360649376053f370ed95e948ffb6
Contents?: true
Size: 785 Bytes
Versions: 12
Compression:
Stored size: 785 Bytes
Contents
module PipeRpc class Hub::Requests def initialize(hub) @hub = hub @requests ={} @uid = 0 wait_for_results_through nil end attr_reader :requests def evaluate(request) @uid += 1 request.id = @uid @requests[@uid] = request @hub.socket.write request @wait.call until request.result.received? request.result.value end def [](id) @requests[id] end def inject_result_for(id, result) if request = @requests.delete(id) request.result.value = result else raise "no request with id '#{id.inspect}'" end end def wait_for_results_through(iteration) @wait = iteration.respond_to?(:call) ? iteration : proc{ @hub.handle_message } end end end
Version data entries
12 entries across 12 versions & 1 rubygems