summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-12-01 23:00:33 +1300
committerGitHub <noreply@github.com>2022-12-01 23:00:33 +1300
commit0436f1e15a8e79ffef5ea412ac1312cbf9f063e6 (patch)
tree456611e5ae13d2c1312a61532ab7a79d642564b6 /include
parent9869bd1d612b489df806cf95bcb56965a02424e0 (diff)
downloadruby-0436f1e15a8e79ffef5ea412ac1312cbf9f063e6.tar.gz
Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)
Diffstat (limited to 'include')
-rw-r--r--include/ruby/internal/intern/cont.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/ruby/internal/intern/cont.h b/include/ruby/internal/intern/cont.h
index 37493009f5..3ee8b08dee 100644
--- a/include/ruby/internal/intern/cont.h
+++ b/include/ruby/internal/intern/cont.h
@@ -39,6 +39,27 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
VALUE rb_fiber_new(rb_block_call_func_t func, VALUE callback_obj);
/**
+ * Creates a Fiber instance from a C-backended block with the specified storage.
+ *
+ * If the given storage is Qundef, this function is equivalent to
+ * rb_fiber_new() which inherits storage from the current fiber.
+ *
+ * If the given storage is Qfalse, this function uses the current fiber's
+ * storage by reference.
+ *
+ * If the given storage is Qnil, this function will lazy initialize the
+ * internal storage which starts of empty (without any inheritance).
+ *
+ * Otherwise, the given storage is used as the internal storage.
+ *
+ * @param[in] func A function, to become the fiber's body.
+ * @param[in] callback_obj Passed as-is to `func`.
+ * @return An allocated new instance of rb_cFiber, which is ready to be
+ * "resume"d.
+ */
+VALUE rb_fiber_new_storage(rb_block_call_func_t func, VALUE callback_obj, VALUE storage);
+
+/**
* Queries the fiber which is calling this function. Any ruby execution
* context has its fiber, either explicitly or implicitly.
*