class Pione::DRbPatch::PioneTCPSocket

PioneTCPSocket is a reply reader thread extension for standard DRbTCPSocket.

Public Class Methods

new(uri, soc, config={}) click to toggle source
Calls superclass method
# File lib/pione/patch/drb-patch.rb, line 73
def initialize(uri, soc, config={})
  super
  @reply_reader = ReplyReader.new
end

Public Instance Methods

alive?() click to toggle source

Return true if connection socket exists.

# File lib/pione/patch/drb-patch.rb, line 104
def alive?
  return (@socket and not(@socket.closed?))
end
send_reply(req_id, succ, result) click to toggle source

Send the reply with request id. Note: this overrides original send_rely.

# File lib/pione/patch/drb-patch.rb, line 99
def send_reply(req_id, succ, result)
  @msg.send_reply(req_id, stream, succ, result)
end
send_request(ref, msg_id, arg, b) click to toggle source

Send the request from client to server.

# File lib/pione/patch/drb-patch.rb, line 79
def send_request(ref, msg_id, arg, b)
  # set watcher
  @reply_reader.add_watcher(Thread.current)

  # send the request
  req_id = @msg.send_request(stream, ref, msg_id, arg, b)

  # start reply reader
  @reply_reader.start(self)

  # wait the reply by using watier table
  succ, result = Pione::DRbPatch.waiter_table.take(req_id, msg_id, arg)

  # remove watcher
  @reply_reader.remove_watcher(Thread.current)

  return succ, result
end