Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5b4b7c007140
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4029f062a46f
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jun 18, 2016

  1. Copy the full SHA
    4f94671 View commit details
  2. Copy the full SHA
    4029f06 View commit details
Showing with 39 additions and 22 deletions.
  1. +6 −2 machine/builtin/fiber.cpp
  2. +31 −18 spec/ruby/core/fiber/resume_spec.rb
  3. +2 −2 spec/ruby/core/thread/thread_variable_key_spec.rb
8 changes: 6 additions & 2 deletions machine/builtin/fiber.cpp
Original file line number Diff line number Diff line change
@@ -135,7 +135,11 @@ namespace rubinius {
vm->fiber()->arguments(), vm->fiber()->block());
vm->set_call_frame(NULL);

value = vm->fiber()->return_value(state);
if(value) {
vm->fiber()->value(state, value);
} else {
vm->fiber()->value(state, cNil);
}

vm->fiber()->invoke_context()->fiber()->restart(state);

@@ -321,7 +325,7 @@ namespace rubinius {
fiber->suspend(state);

// We're back...
return fiber->invoke_context()->fiber()->return_value(state);
return fiber->return_value(state);
}

void Fiber::finalize(STATE, Fiber* fib) {
49 changes: 31 additions & 18 deletions spec/ruby/core/fiber/resume_spec.rb
Original file line number Diff line number Diff line change
@@ -13,27 +13,40 @@
fiber2.resume.should == :fiber2
end

with_feature :fork do
ruby_bug "redmine #595", "2.1.0" do
it "executes the ensure clause" do
rd, wr = IO.pipe
if Kernel::fork then
wr.close
rd.read.should == "executed"
rd.close
else
rd.close
Fiber.new {
begin
Fiber.yield
ensure
wr.write "executed"
end
}.resume
exit 0
# ruby_bug "redmine #595", "2.1.0"
it "executes the ensure clause" do
rd, wr = IO.pipe

pid = Kernel::fork do
rd.close
f = Fiber.new do
begin
Fiber.yield
ensure
wr.write "executed"
end
end

# The apparent issue is that when Fiber.yield executes, control
# "leaves" the "ensure block" and so the ensure clause should run. But
# control really does NOT leave the ensure block when Fiber.yield
# executes. It merely pauses there. To require ensure to run when a
# Fiber is suspended then makes ensure-in-a-Fiber-context different
# than ensure-in-a-Thread-context and this would be very confusing.
f.resume

# When we execute the second #resume call, the ensure block DOES exit,
# the ensure clause runs. This is Ruby behavior as of 2.3.1.
f.resume

exit 0
end

wr.close
Process.waitpid pid

rd.read.should == "executed"
rd.close
end
end
end
4 changes: 2 additions & 2 deletions spec/ruby/core/thread/thread_variable_key_spec.rb
Original file line number Diff line number Diff line change
@@ -11,11 +11,11 @@

it "returns false if the thread variables do not contain 'key'" do
@t.thread_variable_set :a, 2
@t.thread_variable_key?(:b).should be_false
@t.thread_variable?(:b).should be_false
end

it "returns true if the thread variables contain 'key'" do
@t.thread_variable_set :a, 2
@t.thread_variable_key?(:a).should be_true
@t.thread_variable?(:a).should be_true
end
end