drb client-side proxies

M

Mark Volkmann

The source file lib\ruby\1.8\drb\drb.rb defines the class DRbObject. I
don't understand the initialize method. Why would I ever want to pass
something other than nil for the first parameter? The comment above
the initialize method says that is used to create a proxy/stub for a
local object. Why would I want to do that?

The typical way to use this is
=20
proxy =3D DRbObject.new(nil, url) =20

--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
 
E

Eric Hodel

The source file lib\ruby\1.8\drb\drb.rb defines the class DRbObject. I
don't understand the initialize method. Why would I ever want to pass
something other than nil for the first parameter? The comment above
the initialize method says that is used to create a proxy/stub for a
local object. Why would I want to do that?

The typical way to use this is

proxy = DRbObject.new(nil, url)

You can pass DRbObjects across the wire, so you could wrap a local
object and pass the DRbObject across the wire to the other side. If
you look around in drb.rb you'll see several places where it is used.
 
M

Mark Volkmann

On 14 Aug 2005, at 12:40, Mark Volkmann wrote:
=20
=20
You can pass DRbObjects across the wire, so you could wrap a local
object and pass the DRbObject across the wire to the other side. If
you look around in drb.rb you'll see several places where it is used.

Are you saying that this is a way to force a pass by reference?
I can also do that with DRbUndumped.
Are these blocks of code equivalent in what they accomplish?

obj.extend DRbUndumped
remote_obj.some_method(obj)

remote_obj.some_method(DRbObject.new(obj))

--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
 
E

Eric Hodel

Are you saying that this is a way to force a pass by reference?
I can also do that with DRbUndumped.
Are these blocks of code equivalent in what they accomplish?

obj.extend DRbUndumped
remote_obj.some_method(obj)

remote_obj.some_method(DRbObject.new(obj))

Yes.

DRbUndumped overrides _dump which causes a DRbObject to be created
wrapping obj.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top