Introduce Fiber#storage for inheritable fiber-scoped variables. (#6612)

This commit is contained in:
Samuel Williams 2022-12-01 23:00:33 +13:00 committed by GitHub
parent 9869bd1d61
commit 0436f1e15a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-12-01 10:00:52 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
10 changed files with 442 additions and 56 deletions

View file

@ -766,7 +766,8 @@ next_init(VALUE obj, struct enumerator *e)
{
VALUE curr = rb_fiber_current();
e->dst = curr;
e->fib = rb_fiber_new(next_i, obj);
// We inherit the fiber storage by reference, not by copy, by specifying Qfalse here.
e->fib = rb_fiber_new_storage(next_i, obj, Qfalse);
e->lookahead = Qundef;
}