Rinda::TupleEntry (Class)

In: rinda/tuplespace.rb
Parent: Object

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

Methods

[]   alive?   cancel   canceled?   expired?   fetch   make_expires   make_tuple   new   renew   size   value  

Attributes

expires  [RW] 

Included Modules

DRbUndumped

Public Class methods

[Source]

# File rinda/tuplespace.rb, line 22
    def initialize(ary, sec=nil)
      @cancel = false
      @ary = make_tuple(ary)
      @renewer = nil
      renew(sec)
    end

Public Instance methods

Accessor method for the tuple.

[Source]

# File rinda/tuplespace.rb, line 88
    def [](key)
      @ary[key]
    end

[Source]

# File rinda/tuplespace.rb, line 34
    def alive?
      !canceled? && !expired?
    end

[Source]

# File rinda/tuplespace.rb, line 30
    def cancel
      @cancel = true
    end

[Source]

# File rinda/tuplespace.rb, line 42
    def canceled?; @cancel; end

Has this tuple expired? (true/false).

[Source]

# File rinda/tuplespace.rb, line 45
    def expired?
      return true unless @expires
      return false if @expires > Time.now
      return true if @renewer.nil?
      renew(@renewer)
      return true unless @expires
      return @expires < Time.now
    end

[Source]

# File rinda/tuplespace.rb, line 92
    def fetch(key)
      @ary.fetch(key)
    end

Create an expiry time. Called with:

true:the expiry time is the start of 1970 (i.e. expired).
nil:it is Tue Jan 19 03:14:07 GMT Standard Time 2038 (i.e. when UNIX clocks will die)

otherwise it is sec seconds into the future.

[Source]

# File rinda/tuplespace.rb, line 76
    def make_expires(sec=nil)
      case sec
      when Numeric
        Time.now + sec
      when true
        Time.at(1)
      when nil
        Time.at(2**31-1)
      end
    end

Create a new tuple from the supplied object (array-like).

[Source]

# File rinda/tuplespace.rb, line 102
    def make_tuple(ary)
      Rinda::Tuple.new(ary)
    end

Reset the expiry data according to the supplied argument. If the argument is:

nil:it is set to expire in the far future.
false:it has expired.
Numeric:it will expire in that many seconds.

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

[Source]

# File rinda/tuplespace.rb, line 63
    def renew(sec_or_renewer)
      sec, @renewer = get_renewer(sec_or_renewer)
      @expires = make_expires(sec)
    end

The size of the tuple.

[Source]

# File rinda/tuplespace.rb, line 97
    def size
      @ary.size
    end

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

[Source]

# File rinda/tuplespace.rb, line 40
    def value; @ary.value; end

[Validate]