зеркало из https://github.com/github/ruby.git
Revert "Fix Fiber#transfer"
This reverts commit fa8ac91e95
.
Previous behavior is intentional.
This commit is contained in:
Родитель
65e8267938
Коммит
4c3e3b8028
3
cont.c
3
cont.c
|
@ -2226,8 +2226,7 @@ static VALUE
|
|||
rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fiber_value)
|
||||
{
|
||||
rb_fiber_t *fiber = fiber_ptr(fiber_value);
|
||||
fiber_current()->transferred = 1;
|
||||
fiber->transferred = 0;
|
||||
fiber->transferred = 1;
|
||||
return fiber_switch(fiber, argc, argv, 0, PASS_KW_SPLAT);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,19 +42,10 @@ describe "Fiber#transfer" do
|
|||
fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
it "raises a FiberError when transferring to a Fiber which resumes itself" do
|
||||
fiber = Fiber.new { fiber.resume }
|
||||
-> { fiber.transfer }.should raise_error(FiberError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '2.7' do
|
||||
it "allows transferring to a Fiber which resumes itself" do
|
||||
fiber = Fiber.new { fiber.resume 1 }
|
||||
fiber.transfer.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
it "works if Fibers in different Threads each transfer to a Fiber in the same Thread" do
|
||||
# This catches a bug where Fibers are running on a thread-pool
|
||||
|
|
|
@ -222,8 +222,8 @@ class TestFiber < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_resume_self
|
||||
f = Fiber.new {f.resume 1}
|
||||
assert_equal(1, f.transfer)
|
||||
f = Fiber.new {f.resume}
|
||||
assert_raise(FiberError, '[ruby-core:23651]') {f.transfer}
|
||||
end
|
||||
|
||||
def test_fiber_transfer_segv
|
||||
|
@ -289,13 +289,15 @@ class TestFiber < Test::Unit::TestCase
|
|||
assert_raise(FiberError){
|
||||
g=nil
|
||||
f=Fiber.new{
|
||||
g.transfer
|
||||
g.resume
|
||||
g.resume
|
||||
}
|
||||
g=Fiber.new{
|
||||
f.resume
|
||||
}
|
||||
f.resume
|
||||
}
|
||||
f.transfer
|
||||
}
|
||||
end
|
||||
|
||||
def test_fork_from_fiber
|
||||
|
|
Загрузка…
Ссылка в новой задаче