Class: DRb::TimerIdConv::TimerHolder2
Do not use. This class is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
MonitorMixin
|
|
Inherits: | Object |
Defined in: | lib/drb/timeridconv.rb |
Class Method Summary
- .new(keeping = 600) ⇒ TimerHolder2 constructor
Instance Method Summary
- #add(obj)
- #fetch(key)
- #invoke_keeper private
- #on_gc private
- #peek(key) private
- #rotate private
Constructor Details
.new(keeping = 600) ⇒ TimerHolder2
# File 'lib/drb/timeridconv.rb', line 21
def initialize(keeping=600) super() @sentinel = Object.new @gc = {} @renew = {} @keeping = keeping @expires = nil end
Instance Method Details
#add(obj)
[ GitHub ]# File 'lib/drb/timeridconv.rb', line 30
def add(obj) synchronize do rotate key = obj.__id__ @renew[key] = obj invoke_keeper return key end end
#fetch(key)
[ GitHub ]# File 'lib/drb/timeridconv.rb', line 40
def fetch(key) synchronize do rotate obj = peek(key) raise InvalidIndexError if obj == @sentinel @renew[key] = obj # KeepIt return obj end end
#invoke_keeper (private)
[ GitHub ]# File 'lib/drb/timeridconv.rb', line 55
def invoke_keeper return if @expires @expires = Time.now + @keeping on_gc end
#on_gc (private)
[ GitHub ]#peek(key) (private)
[ GitHub ]#rotate (private)
[ GitHub ]# File 'lib/drb/timeridconv.rb', line 68
def rotate synchronize do if @expires &.< Time.now @gc = @renew # GCed @renew = {} @expires = @gc.empty? ? nil : Time.now + @keeping end end end