Class: Ruck::RealTimeShreduler

Inherits:
Shreduler show all
Defined in:
lib/ruck/shreduling.rb

Instance Attribute Summary

Attributes inherited from Shreduler

#current_shred, #now, #running, #shreds

Instance Method Summary collapse

Methods inherited from Shreduler

#initialize, #invoke_shred, #next_shred, #remove_shred, #run_one, #spork

Constructor Details

This class inherits a constructor from Ruck::Shreduler

Instance Method Details

#runObject



142
143
144
145
# File 'lib/ruck/shreduling.rb', line 142

def run
  @start_time = Time.now
  super
end

#sim_to(new_now) ⇒ Object



147
148
149
150
151
152
153
154
155
# File 'lib/ruck/shreduling.rb', line 147

def sim_to(new_now)
  actual_now = Time.now
  simulated_now = @start_time + (new_now.to_f / SAMPLE_RATE)
  if simulated_now > actual_now
    sleep(simulated_now - actual_now)
  end
  
  @now = new_now
end