A TupleEntry is a Tuple (i.e. a possible entry in some Tuplespace) together with expiry and cancellation data.
- #
- A
- C
- E
- F
- M
- N
- R
- S
- V
| [RW] | expires |
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.
Source: show
# File lib/rinda/tuplespace.rb, line 27 def initialize(ary, sec=nil) @cancel = false @expires = nil @tuple = make_tuple(ary) @renewer = nil renew(sec) end
Retrieves key from the tuple.
Source: show
# File lib/rinda/tuplespace.rb, line 111 def [](key) @tuple[key] end
A TupleEntry is dead when it is canceled or expired.
Source: show
# File lib/rinda/tuplespace.rb, line 45 def alive? !canceled? && !expired? end
Marks this TupleEntry as canceled.
Source: show
# File lib/rinda/tuplespace.rb, line 38 def cancel @cancel = true end
Returns the canceled status.
Source: show
# File lib/rinda/tuplespace.rb, line 58 def canceled?; @cancel; end
Has this tuple expired? (true/false).
A tuple has expired when its expiry timer based on the sec
argument to initialize runs out.
Source: show
# File lib/rinda/tuplespace.rb, line 66 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
Fetches key from the tuple.
Source: show
# File lib/rinda/tuplespace.rb, line 118 def fetch(key) @tuple.fetch(key) end
Returns an expiry Time based on sec
which can be one of:
Source: show
# File lib/rinda/tuplespace.rb, line 97 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
Creates a Rinda::Tuple for ary.
Source: show
# File lib/rinda/tuplespace.rb, line 132 def make_tuple(ary) Rinda::Tuple.new(ary) end
Reset the expiry time according to sec_or_renewer.
- nil
-
it is set to expire in the far future.
- true
-
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: show
# File lib/rinda/tuplespace.rb, line 85 def renew(sec_or_renewer) sec, @renewer = get_renewer(sec_or_renewer) @expires = make_expires(sec) end