Class: Rack::Timeout::Scheduler::RunEvent

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/timeout/support/scheduler.rb

Overview

stores a proc to run later, and the time it should run at

Direct Known Subclasses

RepeatEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RunEvent

Returns a new instance of RunEvent.



24
25
26
27
# File 'lib/rack/timeout/support/scheduler.rb', line 24

def initialize(*args)
  @cancelled = false
  super(*args)
end

Instance Attribute Details

#monotimeObject

Returns the value of attribute monotime

Returns:

  • (Object)

    the current value of monotime



23
24
25
# File 'lib/rack/timeout/support/scheduler.rb', line 23

def monotime
  @monotime
end

#procObject

Returns the value of attribute proc

Returns:

  • (Object)

    the current value of proc



23
24
25
# File 'lib/rack/timeout/support/scheduler.rb', line 23

def proc
  @proc
end

Instance Method Details

#cancel!Object



29
30
31
# File 'lib/rack/timeout/support/scheduler.rb', line 29

def cancel!
  @cancelled = true
end

#cancelled?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rack/timeout/support/scheduler.rb', line 33

def cancelled?
  !!@cancelled
end

#run!Object



37
38
39
40
# File 'lib/rack/timeout/support/scheduler.rb', line 37

def run!
  return if @cancelled
  proc.call(self)
end