manage fiber status (create|running|resumed|terminated)

This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-05-23 15:24:31 +09:00
parent 93d710117d
commit 76ddf86c72
3 changed files with 29 additions and 6 deletions
+8 -1
View File
@@ -1301,7 +1301,14 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
mrb->c = mrb->c->prev; /* automatic yield at the end */
if (mrb->c->prev->ci == mrb->c->prev->cibase) {
mrb_value exc = mrb_exc_new3(mrb, E_RUNTIME_ERROR, mrb_str_new(mrb, "double resume", 13));
mrb->exc = mrb_obj_ptr(exc);
goto L_RAISE;
}
/* automatic yield at the end */
mrb->c->status = MRB_FIBER_TERMINATED;
mrb->c = mrb->c->prev;
}
ci = mrb->c->ci;
break;