Rinda documentation

M

Mark Volkmann

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

Eric Hodel

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)
 
M

Mark Volkmann

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.
#
# =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"?
 
R

Rick Nooner

See my question below.


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
 
E

Ed Howland

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
 

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

Similar Threads

Rinda frustration 11
Rinda: start_keeper bug? Looking for second opinion 1
Rinda and notifications example? 1
Linda primer? 4
Rinda Notify 0
$SAFE >= 2 3
$SAFE >= 2 1
regexp character classes and + 0

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top