From: "Ara.T.Howard" Date: 2006-09-24T07:21:59+09:00 Subject: Re: Slave class -- Was Re: Ruby, Analysis, and Tons of RAM On Sat, 23 Sep 2006, Joel VanderWerf wrote: > ara.t.howard@noaa.gov wrote: >> http://codeforpeople.com/lib/ruby/slave/ >> http://codeforpeople.com/lib/ruby/slave/slave-0.0.1/README > > Ara, why does Slave.new keep a copy of the object (the one you want to be > served up) on both sides of the fork? > > Wouldn't it make more sense for it to work like this (modifying the example > in slave.rb): > > class Server > def add_two n > n + 2 > end > end > > slave = Slave.new {Server.new} # <-- note addition of {...} > server = slave.object > > p server.add_two(40) #=> 42 > > Slave.new would call the block _only_ in the child, and the parent would > never have an instance of Server, only the drb handle to it. > > This might matter if Server.new consumes resources, sets up a data structure > in memory, opens files, etc. that's a great point joel. i'll add that capability and release on monday or so. right now, if a block is given it's called with the object - but i can detect the case based on whether or not and obj is also passed. thanks a bunch. -a -- in order to be effective truth must penetrate like an arrow - and that is likely to hurt. -- wei wu wei