Parent

Class Index [+]

Quicksearch

MessagePack::RPC::Future

Future describes result of remote procedure call that is initially not known, because it is not yet received. You can wait and get the result with get method.

Attributes

loop[R]
result[RW]
error[RW]

Public Instance Methods

attach_callback {|future| } click to toggle source

Attaches a callback method that is called when the result of remote method is received.

    # File lib/msgpack/rpc/future.rb, line 76
76:         def attach_callback(proc = nil, &block)
77:                 @callback_handler = proc || block
78:         end
get() click to toggle source

Wait for receiving result of remote procedure call and returns its result. If the remote method raises error, then this method raises RemoteError. If the remote procedure call failed with timeout, this method raises TimeoutError. Otherwise this method returns the result of remote method.

    # File lib/msgpack/rpc/future.rb, line 43
43:         def get
44:                 join
45:                 if error.nil?
46:                         if @result_handler
47:                                 return @result_handler.call(@result)
48:                         else
49:                                 return @result
50:                         end
51:                 end
52:                 if @result.nil?
53:                         # compatible error
54:                         raise RuntimeError.new(@error)
55:                 end
56:                 if @error_handler
57:                         @error_handler.call(@error, @result)
58:                 end
59:                 raise RPCError.create(@error, @result)
60:         end
join() click to toggle source

Wait for receiving result of remote procedure call. This method returns self. If a callback method is attached, it will be called.

    # File lib/msgpack/rpc/future.rb, line 65
65:         def join
66:                 until @set
67:                         @loop.run_once
68:                 end
69:                 self
70:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.