mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add multi-threaded I/O test.
This commit is contained in:
parent
e6e9cef06e
commit
9f6a3d0306
Notes:
git
2020-07-20 10:21:25 +09:00
1 changed files with 23 additions and 0 deletions
|
@ -39,4 +39,27 @@ class TestFiberIO < Test::Unit::TestCase
|
||||||
assert_predicate(i, :closed?)
|
assert_predicate(i, :closed?)
|
||||||
assert_predicate(o, :closed?)
|
assert_predicate(o, :closed?)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue