ruby-changes:62318
From: Samuel <ko1@a...>
Date: Mon, 20 Jul 2020 10:21:18 +0900 (JST)
Subject: [ruby-changes:62318] 9f6a3d0306 (master): Add multi-threaded I/O test.
https://git.ruby-lang.org/ruby.git/commit/?id=9f6a3d0306 From 9f6a3d030682e9f99c77c2ef31881f9801c3979e Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Sat, 18 Jul 2020 17:34:54 +1200 Subject: Add multi-threaded I/O test. diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index bf20006..90ac4aa 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -39,4 +39,27 @@ class TestFiberIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_io.rb#L39 assert_predicate(i, :closed?) assert_predicate(o, :closed?) end + + def test_heavy_read + skip unless defined?(UNIXSocket) + + 16.times.map do + thread = Thread.new do + i, o = UNIXSocket.pair + + scheduler = Scheduler.new + Thread.current.scheduler = scheduler + + Fiber do + message = i.read(20) + i.close + end + + Fiber do + o.write("Hello World") + o.close + end + end + end.each(&:join) + end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/