Class: DRb::ThreadObject
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
MonitorMixin
|
|
Inherits: | Object |
Defined in: | lib/drb/drb.rb |
Class Method Summary
- .new(&blk) ⇒ ThreadObject constructor
Instance Attribute Summary
- #alive? ⇒ Boolean readonly
Instance Method Summary
Constructor Details
.new(&blk) ⇒ ThreadObject
# 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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg, *arg, &blk)
[ GitHub ]# 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
Instance Attribute Details
#alive? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/drb/drb.rb', line 1212
def alive? @thread.alive? end
Instance Method Details
#_execute
[ GitHub ]# 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
#kill
[ GitHub ]# File 'lib/drb/drb.rb', line 1216
def kill @thread.kill @thread.join end