Class: Green::Hub::Nio4r::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/green/hub/nio4r.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reactor, fire_at, &clb) ⇒ Timer

Returns a new instance of Timer.



31
32
33
# File 'lib/green/hub/nio4r.rb', line 31

def initialize(reactor, fire_at, &clb)
  @reactor, @fire_at, @clb = reactor, fire_at, clb
end

Instance Attribute Details

#clbObject (readonly)

Returns the value of attribute clb.



30
31
32
# File 'lib/green/hub/nio4r.rb', line 30

def clb
  @clb
end

#fire_atObject (readonly)

Returns the value of attribute fire_at.



30
31
32
# File 'lib/green/hub/nio4r.rb', line 30

def fire_at
  @fire_at
end

#reactorObject (readonly)

Returns the value of attribute reactor.



30
31
32
# File 'lib/green/hub/nio4r.rb', line 30

def reactor
  @reactor
end

Instance Method Details

#<=>(v) ⇒ Object



46
47
48
# File 'lib/green/hub/nio4r.rb', line 46

def <=>(v)
  @fire_at <=> v.fire_at
end

#green_cancelObject



40
41
42
43
44
# File 'lib/green/hub/nio4r.rb', line 40

def green_cancel
  return if @canceled || @runned
  @canceled = true
  reactor.cancel_timer self
end

#runObject



35
36
37
38
# File 'lib/green/hub/nio4r.rb', line 35

def run
  @runned = true
  clb.call
end