Class: Enginevib::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/enginevib/scheduler.rb

Overview

Defines the scheduler class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deadline, tolerance, &block) ⇒ Scheduler



10
11
12
13
14
15
16
# File 'lib/enginevib/scheduler.rb', line 10

def initialize(deadline, tolerance, &block)
  @deadline = deadline
  @block = block
  @tolerance = tolerance
  @stats = Stats.new
  @averager = Averager.new
end

Instance Attribute Details

#averagerObject

Returns the value of attribute averager.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def averager
  @averager
end

#blockObject

Returns the value of attribute block.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def block
  @block
end

#deadlineObject

Returns the value of attribute deadline.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def deadline
  @deadline
end

#inopObject

Returns the value of attribute inop.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def inop
  @inop
end

#statsObject

Returns the value of attribute stats.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def stats
  @stats
end

#toleranceObject

Returns the value of attribute tolerance.



8
9
10
# File 'lib/enginevib/scheduler.rb', line 8

def tolerance
  @tolerance
end

Instance Method Details

#startObject



18
19
20
# File 'lib/enginevib/scheduler.rb', line 18

def start
  preempt_rt { loop { tick } }
end

#tickObject



22
23
24
25
26
27
28
29
30
# File 'lib/enginevib/scheduler.rb', line 22

def tick
  execution_time = execute_block

  actual_wait_time = wait_for_next_tick(execution_time)

  measure_time = measure_execution(execution_time, actual_wait_time)

  verify_measure_time(execution_time, actual_wait_time, measure_time)
end