| 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.
| expires | [RW] |
# File rinda/tuplespace.rb, line 22 def initialize(ary, sec=nil) @cancel = false @ary = make_tuple(ary) @renewer = nil renew(sec) end
Has this tuple expired? (true/false).
# 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
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.
# 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).
# 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.
# File rinda/tuplespace.rb, line 63 def renew(sec_or_renewer) sec, @renewer = get_renewer(sec_or_renewer) @expires = make_expires(sec) end