类 DRb::WeakIdConv::WeakSet

公共类方法

new() 点击切换源代码
调用超类方法 MonitorMixin::new
# File lib/drb/weakidconv.rb, line 14
def initialize
  super()
  @immutable = {}
  @map = ObjectSpace::WeakMap.new
end

公共实例方法

add(obj) 点击切换源代码
# File lib/drb/weakidconv.rb, line 20
def add(obj)
  synchronize do
    begin
      @map[obj] = self
    rescue ArgumentError
      @immutable[obj.__id__] = obj
    end
    return obj.__id__
  end
end
fetch(ref) 点击切换源代码
# File lib/drb/weakidconv.rb, line 31
def fetch(ref)
  synchronize do
    @immutable.fetch(ref) {
      @map.each { |key, _|
        return key if key.__id__ == ref
      }
      raise RangeError.new("invalid reference")
    }
  end
end