Class: RubyVolt::Base::AsyncCall

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_volt/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(procedure, *parameters) ⇒ AsyncCall

Returns a new instance of AsyncCall.



7
8
9
10
11
# File 'lib/ruby_volt/base.rb', line 7

def initialize(procedure, *parameters)
  @opaque = Helper.uniq_bytes(8) # Not even necessary
  @args = [procedure, @opaque, *parameters]
  @queue = SizedQueue.new(1)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/ruby_volt/base.rb', line 5

def args
  @args
end

#opaqueObject (readonly)

Returns the value of attribute opaque.



5
6
7
# File 'lib/ruby_volt/base.rb', line 5

def opaque
  @opaque
end

#response_msgObject (readonly)

Returns the value of attribute response_msg.



5
6
7
# File 'lib/ruby_volt/base.rb', line 5

def response_msg
  @response_msg
end

Instance Method Details

#accept_response(response_msg) ⇒ Object



17
18
19
20
# File 'lib/ruby_volt/base.rb', line 17

def accept_response(response_msg)
  @queue.push(response_msg)
  @queue.close
end

#dispatch(&block) ⇒ Object



22
23
24
25
26
# File 'lib/ruby_volt/base.rb', line 22

def dispatch(&block)
  if @response_msg ||= @queue.pop
    InvocationResponse.new(@response_msg).unpack!(&block)
  end
end

#inspectObject



13
14
15
# File 'lib/ruby_volt/base.rb', line 13

def inspect
  "#<#{self.class} ready=#{!@queue.empty?}>"
end