Module: Ruck::ShredConvenienceMethods

Defined in:
lib/ruck/shreduler.rb

Instance Method Summary collapse

Instance Method Details

#wait_on(event) ⇒ Object

sleeps, waiting on the given event on the default EventClock of the global Shreduler



111
112
113
114
# File 'lib/ruck/shreduler.rb', line 111

def wait_on(event)
  $shreduler.shredule(Shred.current, event, $shreduler.event_clock)
  Shred.current.pause
end

#yield(dt, clock = nil) ⇒ Object

yields the given amount of time on the global Shreduler, using the provided Clock if given



103
104
105
106
107
# File 'lib/ruck/shreduler.rb', line 103

def yield(dt, clock = nil)
  clock ||= $shreduler.clock
  $shreduler.shredule(Shred.current, clock.now + dt, clock)
  Shred.current.pause
end