Rinda documentation

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.

···

--
R. Mark Volkmann
Partner, Object Computing, Inc.

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

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

···

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.

   ##
   # 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 [i] }
   #
   # 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 - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

See my question below.

> 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 [i] }
   #
   # 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"?

···

On 9/17/05, Eric Hodel <drbrain@segment7.net> wrote:

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

     #
     # The TupleSpace will also notify you of the 'close' event when the
     # NotifyTemplateEntry has expired.

     def notify(event, tuple, sec=nil)

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

--
R. Mark Volkmann
Partner, Object Computing, Inc.

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

···

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"?

--
Rick Nooner
rick@nooner.net

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

just curious.

Ed

···

On 9/28/05, Rick Nooner <rick@nooner.net> 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

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

Rick

···

On Sat, Oct 01, 2005 at 01:10:09AM +0900, Ed Howland wrote:

On 9/28/05, Rick Nooner <rick@nooner.net> 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

--
Rick Nooner
rick@nooner.net