Eric Hodel
7/30/2007 11:55:00 PM
On Jul 30, 2007, at 13:35, Jay McGavren wrote:
> On Jul 30, 8:33 am, "Chris Carter" <cdcar...@gmail.com> wrote:
>> You should probably just extend the array with DRbUndumped, that will
>> (IIRC) speed up the appending, and allow << to work properly.
>
> Thusly, yes?
>
> Server:
>
> require 'drb'
> class UndumpedArray < Array
> include DRbUndumped
> end
> class TestServer
> attr_accessor :items
> def initialize
> @items = UndumpedArray.new
Get rid of UndumpedArray.
@items = Array.new
@items.extend DRbUndumped
> end
> def add
> sum = 0
> @items.each {|item| sum += item}
> sum
> end
> end
> server = TestServer.new
> DRb.start_service('druby://localhost:9000', server)
> DRb.thread.join
>
> Client:
>
> require 'drb'
> DRb.start_service()
> obj = DRbObject.new(nil, 'druby://localhost:9000')
> obj.items << 1
> obj.items << 2
> puts obj.add #Gives '3'.
>
> Seems to work pretty well. DRbUndumped may be the solution to my
> concerns about network overhead as well.
>
> Thanks to everyone for the assistance!
>
> -Jay
>
--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars