Sha256: 898a19cb71fa7352ef95fc71b0953015ec3f780ca5a04feac5129730cb967478

Contents?: true

Size: 616 Bytes

Versions: 27

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'

# Thread.event_selector = Gyro::Selector
# Thread.current.setup_fiber_scheduling

t = Gyro::Timer.new(1, 1)
s = spin {
  last = Time.now
  loop do
    t.await
    now = Time.now
    puts "elapsed: #{now - last}"
    last = now
  end
}
s.await
exit!

p :go_to_sleep
sleep 1
p :wake_up

puts "*" * 60

t = Thread.new {
  Thread.current.setup_fiber_scheduling

  spin {
    p :go_to_sleep1
    sleep 1
    p :wake_up1
  }

  spin {
    p :go_to_sleep2
    sleep 2
    p :wake_up2
  }

  p :waiting
  suspend
}

t.join

at_exit {
  p :at_exit
}

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
polyphony-0.45.0 examples/core/xx-thread-selector-sleep.rb
polyphony-0.44.0 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.11 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.10 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.9 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.8 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.6 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.5 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.4 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.3 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.2 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43.1 examples/core/xx-thread-selector-sleep.rb
polyphony-0.43 examples/core/xx-thread-selector-sleep.rb
polyphony-0.42 examples/core/xx-thread-selector-sleep.rb
polyphony-0.41 examples/core/xx-thread-selector-sleep.rb
polyphony-0.40 examples/core/xx-thread-selector-sleep.rb
polyphony-0.39 examples/core/xx-thread-selector-sleep.rb
polyphony-0.38 examples/core/xx-thread-selector-sleep.rb
polyphony-0.36 examples/core/xx-thread-selector-sleep.rb
polyphony-0.34 examples/core/xx-thread-selector-sleep.rb