Skip to content

Commit dfa0897

Browse files
authored
Enumerator should use a non-blocking fiber. (#10478)
1 parent eaa6e4b commit dfa0897

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

cont.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ rb_fiber_initialize(int argc, VALUE* argv, VALUE self)
23822382
VALUE
23832383
rb_fiber_new_storage(rb_block_call_func_t func, VALUE obj, VALUE storage)
23842384
{
2385-
return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 1, storage);
2385+
return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 0, storage);
23862386
}
23872387

23882388
VALUE

internal/parse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ rb_parser_string_t *rb_str_to_parser_string(rb_parser_t *p, VALUE str);
6868
void rb_parser_warn_duplicate_keys(struct parser_params *p, NODE *hash);
6969
int rb_parser_dvar_defined_ref(struct parser_params*, ID, ID**);
7070
ID rb_parser_internal_id(struct parser_params*);
71+
VALUE rb_parser_node_case_when_optimizable_literal(struct parser_params *p, const NODE *const node);
7172
int rb_parser_reg_fragment_check(struct parser_params*, rb_parser_string_t*, int);
7273
int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc);
7374
int rb_parser_local_defined(struct parser_params *p, ID id, const struct rb_iseq_struct *iseq);

test/fiber/test_enumerator.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ def test_read_characters
4242
assert_predicate(i, :closed?)
4343
assert_predicate(o, :closed?)
4444
end
45+
46+
def enumerator_fiber_is_nonblocking
47+
enumerator = Enumerator.new do |yielder|
48+
yielder << Fiber.current.blocking?
49+
end
50+
51+
assert_equal(false, enumerator.next)
52+
end
4553
end

0 commit comments

Comments
 (0)