summaryrefslogtreecommitdiff
path: root/test/fiber
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-07-18 17:34:54 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-07-20 13:20:58 +1200
commit9f6a3d030682e9f99c77c2ef31881f9801c3979e (patch)
tree6922139d365ea34d8c865dcd068ad3366cc8d0e8 /test/fiber
parente6e9cef06e9023a80991518297d9f2c0c12488ce (diff)
Add multi-threaded I/O test.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3323
Diffstat (limited to 'test/fiber')
-rw-r--r--test/fiber/test_io.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb
index bf200061d8..90ac4aa5cd 100644
--- a/test/fiber/test_io.rb
+++ b/test/fiber/test_io.rb
@@ -39,4 +39,27 @@ class TestFiberIO < Test::Unit::TestCase
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