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
rick / nooner.net
http://www.nooner.net