Project

General

Profile

Bug #7714 » ruby-doc_drb-20130117.patch

vbatts (Vincent Batts), 01/18/2013 03:38 PM

View differences:

lib/drb/drb.rb
# An exception wrapping an error object
class DRbRemoteError < DRbError
# Create a new DRb::DRbRemoteError
def initialize(error)
@reason = error.class.to_s
super("#{error.message} (#{error.class})")
......
end
end
# Class to wrap an Array.
#
# === Description
#
# A DRbArray can be provided in a DRb call. When the marshalled value
# of a DRbArray object is unmarshalled, it returns the wrapped Array.
#
#
# === Examples
#
# a = %w{ cats and dogs }
# => ["cats", "and", "dogs"]
# da = DRb::DRbArray.new(a)
# => #<DRb::DRbArray:0x0000000068b0f0 @ary=["cats", "and", "dogs"]>
# bin = Marshal.dump(h)
# => "\x04\bu:\x12DRb::DRbArray*\x04\b[\bI\"\tcats\x06:\x06ETI\"\band\x06;\0TI\"\tdogs\x06;\0T"
# Marshal.load(bin)
# => ["cats", "and", "dogs"]
#
class DRbArray
# Create a DRb::DRbArray object
#
# +ary+ is an Array
def initialize(ary)
@ary = ary.collect { |obj|
if obj.kind_of? DRbUndumped
......
}
end
def self._load(s)
def self._load(s) # :nodoc:
Marshal::load(s)
end
def _dump(lv)
def _dump(lv) # :nodoc:
Marshal.dump(@ary)
end
end
......
end
private
def make_proxy(obj, error=false)
def make_proxy(obj, error=false) # :nodoc:
if error
DRbRemoteError.new(obj)
else
......
self.new_with(uri, ref)
end
# Create a DRb::DRbObject given the reference information to the
# remote host uri String, and ref
def self.new_with(uri, ref)
it = self.allocate
it.instance_variable_set(:@uri, uri)
......
# Set the default acl.
#
# See DRb::DRbServer.default_acl.
# XXX needs more info
def install_acl(acl)
DRbServer.default_acl(acl)
end
module_function :install_acl
@mutex = Mutex.new
# Get the semaphore for this DRb module
#
# return's a Mutex instance
def mutex
@mutex
end
module_function :mutex
@server = {}
# Recored the DRb::DRbServer +server+
#
# This is called when a new DRb::DRbServer instance is created.
#
# require 'drb'
#
# s = DRb::DRbServer.new
# => #<DRb::DRbServer:0x00000001dcb440 @config={:idconv=>#<DRb::...
# DRb.fetch_server(s.uri)
# => #<DRb::DRbServer:0x00000001dcb440 @config={:idconv=>#<DRb::...
#
def regist_server(server)
@server[server.uri] = server
mutex.synchronize do
......
end
module_function :regist_server
# Remove the DRb::DRbServer +server+ from the registered list
def remove_server(server)
@server.delete(server.uri)
end
module_function :remove_server
# Return the DRb::DRbServer object, provided the String +uri+.
#
# This is provided from the registered servers.
# See also #regist_server and #remove_server
def fetch_server(uri)
@server[uri]
end
(1-1/2)