Rinda documentation

Discussion in 'Ruby' started by Mark Volkmann, Sep 18, 2005.

  1. Documentation on Rinda seems hard to come by, at least in English.
    Can anyone verify what the move and notify methods in Rinda::TupleSpace do?
    My best guess is that move moves a tuple from one TupleSpace to another
    and notify notifies you when a tuple matching a given pattern appears
    in a given TupleSpace.

    --=20
    R. Mark Volkmann
    Partner, Object Computing, Inc.
     
    Mark Volkmann, Sep 18, 2005
    #1
    1. Advertising

  2. Mark Volkmann

    Eric Hodel Guest

    On 17 Sep 2005, at 18:03, Mark Volkmann wrote:

    > Documentation on Rinda seems hard to come by, at least in English.
    > Can anyone verify what the move and notify methods in
    > Rinda::TupleSpace do?
    > My best guess is that move moves a tuple from one TupleSpace to
    > another
    > and notify notifies you when a tuple matching a given pattern appears
    > in a given TupleSpace.


    See Rinda::TupleSpaceProxy for an example of how #move is used.

    #notify works this way, (from a doc patch submitted to Masatoshi Seki):

    ##
    # A NotifyTemplateEntry is returned by TupleSpace#notify and is
    notified of
    # TupleSpace changes. You may receive either your subscribed
    event or the
    # 'close' event when iterating over notifications.
    #
    # See TupleSpace#notify_event for valid notification types.
    #
    # == Example
    #
    # ts = Rinda::TupleSpace.new
    # observer = ts.notify 'write', [nil]
    #
    # Thread.start do
    # observer.each { |t| p t }
    # end
    #
    # 3.times { |i| ts.write }
    #
    # Outputs:
    #
    # ['write', [0]]
    # ['write', [1]]
    # ['write', [2]]

    class NotifyTemplateEntry < TemplateEntry

    and

    ##
    # Registers for notifications of +event+. Returns a
    NotifyTemplateEntry.
    # See NotifyTemplateEntry for examples of how to listen for
    notifications.
    #
    # +event+ can be:
    # 'write':: A tuple was added
    # 'take':: A tuple was taken or moved
    # 'delete':: A tuple was lost after being overwritten or expiring
    #
    # The TupleSpace will also notify you of the 'close' event when the
    # NotifyTemplateEntry has expired.

    def notify(event, tuple, sec=nil)

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
     
    Eric Hodel, Sep 18, 2005
    #2
    1. Advertising

  3. See my question below.

    On 9/17/05, Eric Hodel <> wrote:
    >
    > On 17 Sep 2005, at 18:03, Mark Volkmann wrote:
    >
    > > Documentation on Rinda seems hard to come by, at least in English.
    > > Can anyone verify what the move and notify methods in
    > > Rinda::TupleSpace do?
    > > My best guess is that move moves a tuple from one TupleSpace to
    > > another
    > > and notify notifies you when a tuple matching a given pattern appears
    > > in a given TupleSpace.

    >
    > See Rinda::TupleSpaceProxy for an example of how #move is used.
    >
    > #notify works this way, (from a doc patch submitted to Masatoshi Seki):
    >
    > ##
    > # A NotifyTemplateEntry is returned by TupleSpace#notify and is
    > notified of
    > # TupleSpace changes. You may receive either your subscribed
    > event or the
    > # 'close' event when iterating over notifications.
    > #
    > # See TupleSpace#notify_event for valid notification types.
    > #
    > # =3D=3D Example
    > #
    > # ts =3D Rinda::TupleSpace.new
    > # observer =3D ts.notify 'write', [nil]
    > #
    > # Thread.start do
    > # observer.each { |t| p t }
    > # end
    > #
    > # 3.times { |i| ts.write }
    > #
    > # Outputs:
    > #
    > # ['write', [0]]
    > # ['write', [1]]
    > # ['write', [2]]
    >
    > class NotifyTemplateEntry < TemplateEntry
    >
    > and
    >
    > ##
    > # Registers for notifications of +event+. Returns a
    > NotifyTemplateEntry.
    > # See NotifyTemplateEntry for examples of how to listen for
    > notifications.
    > #
    > # +event+ can be:
    > # 'write':: A tuple was added
    > # 'take':: A tuple was taken or moved
    > # 'delete':: A tuple was lost after being overwritten or expiring


    Under what circumstances is a tuple "overwritten"?

    > #
    > # The TupleSpace will also notify you of the 'close' event when the
    > # NotifyTemplateEntry has expired.
    >
    > def notify(event, tuple, sec=3Dnil)
    >
    > --
    > Eric Hodel - - http://segment7.net
    > FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    >
    >
    >



    --
    R. Mark Volkmann
    Partner, Object Computing, Inc.
     
    Mark Volkmann, Sep 28, 2005
    #3
  4. Mark Volkmann

    Rick Nooner Guest

    On Thu, Sep 29, 2005 at 12:06:13AM +0900, Mark Volkmann wrote:
    > See my question below.
    >
    > > # See NotifyTemplateEntry for examples of how to listen for
    > > notifications.
    > > #
    > > # +event+ can be:
    > > # 'write':: A tuple was added
    > > # 'take':: A tuple was taken or moved
    > > # 'delete':: A tuple was lost after being overwritten or expiring

    >
    > Under what circumstances is a tuple "overwritten"?
    >


    In looking at the code in rinda/tuplespace.rb, it seems that a delete
    event will only be sent when a tuple expires and the tuplespace garbage
    collector is run:

    def keep_clean
    synchronize do
    @read_waiter.delete_unless_alive.each do |e|
    e.signal
    end
    @take_waiter.delete_unless_alive.each do |e|
    e.signal
    end
    @notify_waiter.delete_unless_alive.each do |e|
    e.notify(['close'])
    end
    @bag.delete_unless_alive.each do |e|
    notify_event('delete', e.value)
    end
    end
    end

    And when a write event happens where the tuple being written is expired:

    def write(tuple, sec=nil)
    entry = TupleEntry.new(tuple, sec)
    synchronize do
    if entry.expired?
    @read_waiter.find_all_template(entry).each do |template|
    template.read(tuple)
    end
    notify_event('write', entry.value)
    notify_event('delete', entry.value)
    else
    @bag.push(entry)
    @read_waiter.find_all_template(entry).each do |template|
    template.read(tuple)
    end
    @take_waiter.find_all_template(entry).each do |template|
    template.signal
    end
    notify_event('write', entry.value)
    end
    end
    entry
    end

    You can expire a tuple on write using the write method a giving a value of 0
    for sec.

    I am not sure why this would be useful.

    Rick

    --
    Rick Nooner

    http://www.nooner.net
     
    Rick Nooner, Sep 28, 2005
    #4
  5. Mark Volkmann

    Ed Howland Guest

    On 9/28/05, Rick Nooner <> wrote:
    >
    > You can expire a tuple on write using the write method a giving a value o=

    f 0
    > for sec.
    >
    > I am not sure why this would be useful.
    >
    > Rick


    Wouldn't this be useful to notify any observers of that tuple's template?

    just curious.

    Ed
     
    Ed Howland, Sep 30, 2005
    #5
  6. Mark Volkmann

    Rick Nooner Guest

    On Sat, Oct 01, 2005 at 01:10:09AM +0900, Ed Howland wrote:
    > On 9/28/05, Rick Nooner <> wrote:
    > >
    > > You can expire a tuple on write using the write method a giving a value of 0
    > > for sec.
    > >
    > > I am not sure why this would be useful.
    > >
    > > Rick

    >
    > Wouldn't this be useful to notify any observers of that tuple's template?
    >
    > just curious.
    >
    > Ed


    I suppose it would. I hadn't thought of that.

    Rick

    --
    Rick Nooner

    http://www.nooner.net
     
    Rick Nooner, Sep 30, 2005
    #6
    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. Shashank Date

    Working with Ring/Rinda

    Shashank Date, Nov 30, 2003, in forum: Ruby
    Replies:
    4
    Views:
    125
    Shashank Date
    Nov 30, 2003
  2. Charles Comstock

    Rinda Notify

    Charles Comstock, Dec 26, 2003, in forum: Ruby
    Replies:
    0
    Views:
    105
    Charles Comstock
    Dec 26, 2003
  3. Charles Comstock

    DRb / Rinda Examples

    Charles Comstock, Feb 13, 2004, in forum: Ruby
    Replies:
    2
    Views:
    167
    Charles Comstock
    Feb 15, 2004
  4. Kirk Haines

    Bug in Rinda (Drb 2.0.4)?

    Kirk Haines, May 6, 2004, in forum: Ruby
    Replies:
    2
    Views:
    97
    Kirk Haines
    May 6, 2004
  5. jm
    Replies:
    5
    Views:
    115
    Sam Roberts
    Jan 19, 2005
Loading...

Share This Page