зеркало из https://github.com/github/ruby.git
Add multi-threaded I/O test.
This commit is contained in:
Родитель
e6e9cef06e
Коммит
9f6a3d0306
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче