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.



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

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



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

def monotime
  @monotime
end

#procObject

Returns the value of attribute proc

Returns:

  • (Object)

    the current value of proc



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

def proc
  @proc
end

Instance Method Details

#cancel!Object



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

def cancel!
  @cancelled = true
end

#cancelled?Boolean

Returns:

  • (Boolean)


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

def cancelled?
  !!@cancelled
end

#run!Object



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

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