Allows calling Fiber#resume from C

This patch is effectively reverts to the following:
  - commit dc65b1faf1 (#5782)
  - commit f4c4809750 (#5947)

Ref. #6063
This commit is contained in:
dearblue
2023-12-04 21:48:31 +09:00
parent ad4c35b022
commit ef8b0b7ed8
2 changed files with 5 additions and 7 deletions
-2
View File
@@ -1458,8 +1458,6 @@ MRB_API mrb_value mrb_fiber_new(mrb_state *mrb, const struct RProc *proc);
* Implemented in mruby-fiber
*
* Switches to the specified fiber and executes. Like the `Fiber#resume` method.
*
* @note It can only be called before entering the mruby VM (e.g. in the `main()` function).
*/
MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc, const mrb_value *argv);
+5 -5
View File
@@ -301,19 +301,19 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
* to the next <code>Fiber.yield</code> statement inside the fiber's block
* or to the block value if it runs to completion without any
* <code>Fiber.yield</code>
*
* This method cannot be called from C using <code>mrb_funcall()</code>.
* Use <code>mrb_fiber_resume()</code> function instead.
*/
static mrb_value
fiber_resume(mrb_state *mrb, mrb_value self)
{
const mrb_value *a;
mrb_int len;
mrb_bool vmexec = FALSE;
fiber_check_cfunc(mrb, mrb->c);
mrb_get_args(mrb, "*!", &a, &len);
return fiber_switch(mrb, self, len, a, TRUE, FALSE);
if (mrb->c->ci->cci > 0) {
vmexec = TRUE;
}
return fiber_switch(mrb, self, len, a, TRUE, vmexec);
}
MRB_API mrb_value