Class: RubyVolt::Base::AsyncCall
- Inherits:
-
Object
- Object
- RubyVolt::Base::AsyncCall
- Defined in:
- lib/ruby_volt/base.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#opaque ⇒ Object
readonly
Returns the value of attribute opaque.
-
#response_msg ⇒ Object
readonly
Returns the value of attribute response_msg.
Instance Method Summary collapse
- #accept_response(response_msg) ⇒ Object
- #dispatch(&block) ⇒ Object
-
#initialize(procedure, *parameters) ⇒ AsyncCall
constructor
A new instance of AsyncCall.
- #inspect ⇒ Object
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/ruby_volt/base.rb', line 5 def args @args end |
#opaque ⇒ Object (readonly)
Returns the value of attribute opaque.
5 6 7 |
# File 'lib/ruby_volt/base.rb', line 5 def opaque @opaque end |
#response_msg ⇒ Object (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 |
#inspect ⇒ Object
13 14 15 |
# File 'lib/ruby_volt/base.rb', line 13 def inspect "#<#{self.class} ready=#{!@queue.empty?}>" end |