Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerator should use a non-blocking fiber, change rb_fiber_new to be non-blocking by default. #10481

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ rb_fiber_initialize(int argc, VALUE* argv, VALUE self)
VALUE
rb_fiber_new_storage(rb_block_call_func_t func, VALUE obj, VALUE storage)
{
return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 1, storage);
return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 0, storage);
}

VALUE
Expand Down
8 changes: 8 additions & 0 deletions test/fiber/test_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ def test_read_characters
assert_predicate(i, :closed?)
assert_predicate(o, :closed?)
end

def enumerator_fiber_is_nonblocking
enumerator = Enumerator.new do |yielder|
yielder << Fiber.current.blocking?
end

assert_equal(false, enumerator.next)
end
end