Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Rinda documentation

Reply
Thread Tools

Rinda documentation

 
 
Mark Volkmann
Guest
Posts: n/a
 
      09-18-2005
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.


 
Reply With Quote
 
 
 
 
Eric Hodel
Guest
Posts: n/a
 
      09-18-2005

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



 
Reply With Quote
 
 
 
 
Mark Volkmann
Guest
Posts: n/a
 
      09-28-2005
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 [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"?

> #
> # 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.


 
Reply With Quote
 
Rick Nooner
Guest
Posts: n/a
 
      09-28-2005
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



 
Reply With Quote
 
Ed Howland
Guest
Posts: n/a
 
      09-30-2005
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


 
Reply With Quote
 
Rick Nooner
Guest
Posts: n/a
 
      09-30-2005
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rinda with other protocols jm Ruby 5 01-19-2005 10:32 PM
Bug in Rinda (Drb 2.0.4)? Kirk Haines Ruby 2 05-06-2004 03:41 PM
DRb / Rinda Examples Charles Comstock Ruby 2 02-15-2004 02:44 AM
Rinda Notify Charles Comstock Ruby 0 12-26-2003 07:33 PM
Working with Ring/Rinda Shashank Date Ruby 4 11-30-2003 11:53 PM



Advertisments