add DRbArray, and change yield. [ruby-dev:21773]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7eb52a8cd5
commit
6a512ba9a9
@ -498,6 +498,31 @@ module DRb
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class DRbArray
|
||||||
|
def initialize(ary)
|
||||||
|
@ary = ary.collect { |obj|
|
||||||
|
if obj.kind_of? DRbUndumped
|
||||||
|
DRbObject.new(obj)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Marshal.dump(obj)
|
||||||
|
obj
|
||||||
|
rescue
|
||||||
|
DRbObject.new(obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def self._load(s)
|
||||||
|
Marshal::load(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def _dump(lv)
|
||||||
|
Marshal.dump(@ary)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Handler for sending and receiving drb messages.
|
# Handler for sending and receiving drb messages.
|
||||||
#
|
#
|
||||||
# This takes care of the low-level marshalling and unmarshalling
|
# This takes care of the low-level marshalling and unmarshalling
|
||||||
@ -1344,6 +1369,9 @@ module DRb
|
|||||||
@result = perform_without_block
|
@result = perform_without_block
|
||||||
end
|
end
|
||||||
@succ = true
|
@succ = true
|
||||||
|
if @msg_id == :to_ary && @result.class == Array
|
||||||
|
@result = DRbArray.new(@result)
|
||||||
|
end
|
||||||
return @succ, @result
|
return @succ, @result
|
||||||
rescue StandardError, ScriptError, Interrupt
|
rescue StandardError, ScriptError, Interrupt
|
||||||
@result = $!
|
@result = $!
|
||||||
|
@ -4,6 +4,9 @@ module DRb
|
|||||||
class DRbServer
|
class DRbServer
|
||||||
module InvokeMethod18Mixin
|
module InvokeMethod18Mixin
|
||||||
def block_yield(x)
|
def block_yield(x)
|
||||||
|
if x.size == 1 && x[0].class == Array
|
||||||
|
x[0] = DRbArray.new(x[0])
|
||||||
|
end
|
||||||
block_value = @block.call(*x)
|
block_value = @block.call(*x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ require 'socket'
|
|||||||
require 'drb/drb'
|
require 'drb/drb'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
|
raise(LoadError, "UNIXServer is required") unless defined?(UNIXServer)
|
||||||
|
|
||||||
module DRb
|
module DRb
|
||||||
|
|
||||||
class DRbUNIXSocket < DRbTCPSocket
|
class DRbUNIXSocket < DRbTCPSocket
|
||||||
|
Loading…
x
Reference in New Issue
Block a user