In Files

  • rinda/tuplespace.rb


Included Modules


A TupleEntry is a Tuple (i.e. a possible entry in some Tuplespace) together with expiry and cancellation data.



Public Class Methods

new(ary, sec=nil) click to toggle source

Creates a TupleEntry based on ary with an optional renewer or expiry time sec.

A renewer must implement the renew method which returns a Numeric, nil, or true to indicate when the tuple has expired.

               # File rinda/tuplespace.rb, line 27
def initialize(ary, sec=nil)
  @cancel = false
  @expires = nil
  @tuple = make_tuple(ary)
  @renewer = nil

Public Instance Methods

[](key) click to toggle source

Retrieves key from the tuple.

               # File rinda/tuplespace.rb, line 111
def [](key)
alive?() click to toggle source

A TupleEntry is dead when it is canceled or expired.

               # File rinda/tuplespace.rb, line 45
def alive?
  !canceled? && !expired?
cancel() click to toggle source

Marks this TupleEntry as canceled.

               # File rinda/tuplespace.rb, line 38
def cancel
  @cancel = true
canceled?() click to toggle source

Returns the canceled status.

               # File rinda/tuplespace.rb, line 58
def canceled?; @cancel; end
expired?() click to toggle source

Has this tuple expired? (true/false).

A tuple has expired when its expiry timer based on the sec argument to initialize runs out.

               # File rinda/tuplespace.rb, line 66
def expired?
  return true unless @expires
  return false if @expires >
  return true if @renewer.nil?
  return true unless @expires
  return @expires <
fetch(key) click to toggle source

Fetches key from the tuple.

               # File rinda/tuplespace.rb, line 118
def fetch(key)
make_expires(sec=nil) click to toggle source

Returns an expiry Time based on sec which can be one of:


sec seconds into the future


the expiry time is the start of 1970 (i.e. expired)


it is Tue Jan 19 03:14:07 GMT Standard Time 2038 (i.e. when UNIX clocks will die)

               # File rinda/tuplespace.rb, line 97
def make_expires(sec=nil)
  case sec
  when Numeric + sec
  when true
  when nil**31-1)
make_tuple(ary) click to toggle source

Creates a Rinda::Tuple for ary.

               # File rinda/tuplespace.rb, line 132
def make_tuple(ary)
renew(sec_or_renewer) click to toggle source

Reset the expiry time according to sec_or_renewer.


it is set to expire in the far future.


it has expired.


it will expire in that many seconds.

Otherwise the argument refers to some kind of renewer object which will reset its expiry time.

               # File rinda/tuplespace.rb, line 85
def renew(sec_or_renewer)
  sec, @renewer = get_renewer(sec_or_renewer)
  @expires = make_expires(sec)
size() click to toggle source

The size of the tuple.

               # File rinda/tuplespace.rb, line 125
def size
value() click to toggle source

Return the object which makes up the tuple itself: the Array or Hash.

               # File rinda/tuplespace.rb, line 53
def value; @tuple.value; end

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

blog comments powered by Disqus