Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rinda/tuplespace.rb


A NotifyTemplateEntry is returned by Rinda::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.


ts = Rinda::TupleSpace.new
observer = ts.notify 'write', [nil]

Thread.start do
  observer.each { |t| p t }

3.times { |i| ts.write [i] }


['write', [0]]
['write', [1]]
['write', [2]]

Public Class Methods

new(place, event, tuple, expires=nil) click to toggle source

Creates a new NotifyTemplateEntry that watches place for +event+s that match tuple.

               # File rinda/tuplespace.rb, line 246
def initialize(place, event, tuple, expires=nil)
  ary = [event, Rinda::Template.new(tuple)]
  super(ary, expires)
  @queue = Queue.new
  @done = false

Public Instance Methods

each() click to toggle source

Yields event/tuple pairs until this NotifyTemplateEntry expires.

               # File rinda/tuplespace.rb, line 274
def each # :yields: event, tuple
  while !@done
    it = pop
notify(ev) click to toggle source

Called by TupleSpace to notify this NotifyTemplateEntry of a new event.

               # File rinda/tuplespace.rb, line 256
def notify(ev)
pop() click to toggle source

Retrieves a notification. Raises RequestExpiredError when this NotifyTemplateEntry expires.

               # File rinda/tuplespace.rb, line 264
def pop
  raise RequestExpiredError if @done
  it = @queue.pop
  @done = true if it[0] == 'close'
  return it

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.