mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Allows calling Fiber#resume from C
This patch is effectively reverts to the following: - commitdc65b1faf1(#5782) - commitf4c4809750(#5947) Ref. #6063
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user