DRb object mutation issues

Discussion in 'Ruby' started by Nwallins, Jul 11, 2007.

  1. Nwallins

    Nwallins Guest

    # file 1
    require 'drb/drb'
    require 'thread'
    DRb.start_service("druby://:1234", Hash.new.extend(DRbUndumped))
    DRb.thread.join
    # EOF


    # file 2
    require 'drb/drb'
    d = DRbObject.new_with_uri("druby://:1234")
    d[0] = 'zero'
    d[0] #=> "zero"
    d[0].slice!(0, 1)
    d[0] #=> "zero"

    # file 3
    h = Hash.new
    h[0] = 'zero'
    h[0].slice!(0, 1)
    h[0] #=> "ero"

    # how can I change the state of the distributed hash's values?
     
    Nwallins, Jul 11, 2007
    #1
    1. Advertising

  2. Nwallins wrote:
    > # file 1
    > require 'drb/drb'
    > require 'thread'
    > DRb.start_service("druby://:1234", Hash.new.extend(DRbUndumped))
    > DRb.thread.join
    > # EOF
    >
    >
    > # file 2
    > require 'drb/drb'
    > d = DRbObject.new_with_uri("druby://:1234")
    > d[0] = 'zero'
    > d[0] #=> "zero"
    > d[0].slice!(0, 1)
    > d[0] #=> "zero"
    >
    > # file 3
    > h = Hash.new
    > h[0] = 'zero'
    > h[0].slice!(0, 1)
    > h[0] #=> "ero"
    >
    > # how can I change the state of the distributed hash's values?
    >


    Some options:

    1. make the values DRbUndumped, too.

    2. use non-destructive methods on the values:

    d[0] = d[0].slice(0, 1)

    3. define a method on your front object that handles everything at
    server side, so the client says this:

    idx = 0
    d.slice_at_index(idx,0,1)

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
     
    Joel VanderWerf, Jul 11, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cppaddict

    Self-Mutation with Strategy Object

    cppaddict, Sep 2, 2004, in forum: Java
    Replies:
    3
    Views:
    448
    Michiel Konstapel
    Sep 2, 2004
  2. Miles Keaton
    Replies:
    3
    Views:
    193
    Miles Keaton
    Mar 30, 2005
  3. Kirk Haines

    More DRb; SSL & DRB & errors

    Kirk Haines, Jul 1, 2005, in forum: Ruby
    Replies:
    0
    Views:
    137
    Kirk Haines
    Jul 1, 2005
  4. J. Wook
    Replies:
    16
    Views:
    298
    Robert Klemme
    May 16, 2007
  5. Ittay Dror
    Replies:
    1
    Views:
    144
    Ittay Dror
    Oct 21, 2008
Loading...

Share This Page