In Files

  • drb/timeridconv.rb

Parent

Included Modules

DRb::TimerIdConv::TimerHolder2

Public Class Methods

new(timeout=600) click to toggle source
 
               # File drb/timeridconv.rb, line 11
def initialize(timeout=600)
  super()
  @sentinel = Object.new
  @gc = {}
  @curr = {}
  @renew = {}
  @timeout = timeout
  @keeper = keeper
end
            

Public Instance Methods

add(obj) click to toggle source
 
               # File drb/timeridconv.rb, line 21
def add(obj)
  synchronize do 
    key = obj.__id__
    @curr[key] = obj
    return key
  end
end
            
fetch(key, dv=@sentinel) click to toggle source
 
               # File drb/timeridconv.rb, line 29
def fetch(key, dv=@sentinel)
  synchronize do 
    obj = peek(key)
    if obj == @sentinel
      return dv unless dv == @sentinel
      raise InvalidIndexError
    end
    @renew[key] = obj # KeepIt
    return obj
  end
end
            
include?(key) click to toggle source
 
               # File drb/timeridconv.rb, line 41
def include?(key)
  synchronize do 
    obj = peek(key)
    return false if obj == @sentinel
    true
  end
end
            
peek(key) click to toggle source
 
               # File drb/timeridconv.rb, line 49
def peek(key)
  synchronize do 
    return @curr.fetch(key, @renew.fetch(key, @gc.fetch(key, @sentinel)))
  end
end