Sha256: b0889e6ba42e95c72811b5e84eedd27a211b937f70ba10b67c02176483b182b6

Contents?: true

Size: 605 Bytes

Versions: 5

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'
require 'irb'

$counter = 0
timer = spin do
  throttled_loop(5) do
    $counter += 1
  end
end

# readline blocks the current thread, so we offload it to the blocking-ops
# thread pool. That way, the reactor loop can keep running while waiting for
# readline to return
module ::Readline
  alias_method :orig_readline, :readline
  def readline(*args)
    Polyphony::ThreadPool.process { orig_readline(*args) }
  end
end

at_exit { timer.stop }

puts 'try typing $counter to see the counter incremented in the background'
IRB.start

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
polyphony-0.27 examples/io/xx-irb.rb
polyphony-0.26 examples/io/xx-irb.rb
polyphony-0.25 examples/io/xx-irb.rb
polyphony-0.24 examples/io/xx-irb.rb
polyphony-0.23 examples/io/irb.rb