class DRb::ThreadObject

Parent:
Object
Included modules:
MonitorMixin

Public Class Methods

new(&blk) Show source
# File lib/drb/drb.rb, line 1201
def initialize(&blk)
  super()
  @wait_ev = new_cond
  @req_ev = new_cond
  @res_ev = new_cond
  @status = :wait
  @req = nil
  @res = nil
  @thread = Thread.new(self, &blk)
end
Calls superclass method MonitorMixin::new

Public Instance Methods

_execute() { |req| ... } Show source
# File lib/drb/drb.rb, line 1236
def _execute()
  synchronize do
    @req_ev.wait_until { @status == :req }
    @res = yield(@req)
    @status = :res
    @res_ev.signal
  end
end
alive?() Show source
# File lib/drb/drb.rb, line 1212
def alive?
  @thread.alive?
end
kill() Show source
# File lib/drb/drb.rb, line 1216
def kill
  @thread.kill
  @thread.join
end
method_missing(msg, *arg, &blk) Show source
# File lib/drb/drb.rb, line 1221
def method_missing(msg, *arg, &blk)
  synchronize do
    @wait_ev.wait_until { @status == :wait }
    @req = [msg] + arg
    @status = :req
    @req_ev.broadcast
    @res_ev.wait_until { @status == :res }
    value = @res
    @req = @res = nil
    @status = :wait
    @wait_ev.broadcast
    return value
  end
end

Ruby Core © 1993–2020 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.