Hello:
I am thinking about writing a distributed application in Ruby where the
application would process all computationally intensive activities in a
'dedicated' server. As I was digging thro' drb/drb.rb, I found the
following:
def send_message(ref, msg_id, arg, block) # :nodoc:
@protocol.send_request(ref, msg_id, arg, block)
@protocol.recv_reply
<----------- of interest
end
in the class DRbConn; and
def main_loop
Thread.start(@protocol.accept) do |client|
@grp.add Thread.current
Thread.current['DRb'] = { 'client' => client ,
'server' => self }
loop do
begin
succ = false
invoke_method = InvokeMethod.new(self, client)
succ, result = invoke_method.perform
if !succ && verbose
p result
result.backtrace.each do |x|
puts x
end
end
client.send_reply(succ, result) rescue nil
<----------- of interest
ensure
unless succ
client.close
break
end
end
end
end
end
end
in the class DRbServer.
Clearly, DRb is synchronous. This would mean that my 'client' cannot hand
off the job to the 'server' and do other things when the 'server' is doing
the computationally intensive job (parallel execution of the 'client' and
'server' is not possible as the 'client' will be blocked waiting for reply
from the 'server').
My questions are:
(1) Is there a way for me to make asynchronous calls in DRb; in other words,
am I overlooking that functionality?
(2) If there is no asynchronous call capabilities in DRb, why was that not
added when it could have been easily done (not call client.send_reply and
recv_reply)? Is there a technical reason for it?
Any help will be greatly appreciated.
Thanks,
Madan.