Class: Ruck::RealTime::RealTimeShreduler
- Inherits:
-
Shreduler
- Object
- Shreduler
- Ruck::RealTime::RealTimeShreduler
- Defined in:
- lib/ruck/realtime/real_time_shreduler.rb
Overview
This is like the RealTimeShreduler example in the ruck README, except it tracks when it started so that it can detect and correct for drift over time.
Instance Method Summary collapse
Instance Method Details
#fast_forward(dt) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ruck/realtime/real_time_shreduler.rb', line 15 def fast_forward(dt) super actual_now = Time.now - @start_time @simulated_now += dt if @simulated_now > actual_now sleep(@simulated_now - actual_now) end end |
#run ⇒ Object
9 10 11 12 13 |
# File 'lib/ruck/realtime/real_time_shreduler.rb', line 9 def run @start_time = Time.now @simulated_now = 0 super end |