Skip to content

Commit

Permalink
Enumerator should use a non-blocking fiber, change rb_fiber_new to …
Browse files Browse the repository at this point in the history
…be non-blocking by default. (#10481)
  • Loading branch information
ioquatix committed Apr 7, 2024
1 parent cccffef commit 5d1702e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cont.c
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
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

0 comments on commit 5d1702e

Please sign in to comment.