Sha256: c04df90474d3b9a52caff71c9ca1111774919f6e0d9cf7fed3289ffb3b6e1832
Contents?: true
Size: 768 Bytes
Versions: 9
Compression:
Stored size: 768 Bytes
Contents
# frozen_string_literal: true require_relative 'helper' class EventTest < MiniTest::Test def test_that_event_receives_signal_across_threads count = 0 a = Polyphony::Event.new spin { a.await count += 1 } snooze t = Thread.new do orig_sleep 0.001 a.signal end suspend assert_equal 1, count ensure t&.kill t&.join end def test_that_event_coalesces_signals count = 0 a = Polyphony::Event.new coproc = spin { loop { a.await count += 1 spin { coproc.stop } } } snooze t = Thread.new do orig_sleep 0.001 3.times { a.signal } end coproc.await assert_equal 1, count ensure t&.kill t&.join end end
Version data entries
9 entries across 9 versions & 1 rubygems