IO_METHOD(IoCoroutine, run) { /*doc Coroutine run Runs receiver and returns self. */ IoCoroutine_rawRun(self); return IoCoroutine_rawResult(self); }
void IoCoroutine_try(IoCoroutine *self, IoObject *target, IoObject *locals, IoMessage *message) { IoCoroutine *currentCoro = (IoCoroutine *)IoState_currentCoroutine((IoState *)IOSTATE); IoCoroutine_rawSetRunTarget_(self, target); IoCoroutine_rawSetRunLocals_(self, locals); IoCoroutine_rawSetRunMessage_(self, message); IoCoroutine_rawSetParentCoroutine_(self, currentCoro); IoCoroutine_rawRun(self); }
IoObject *IoCoroutine_rawResume(IoCoroutine *self) { if(DATA(self)->cid) { IoCoroutine *current = IoState_currentCoroutine(IOSTATE); IoState_setCurrentCoroutine_(IOSTATE, self); //printf("IoCoroutine resuming %p\n", (void *)self); Coro_switchTo_(IoCoroutine_rawCoro(current), IoCoroutine_rawCoro(self)); //IoState_setCurrentCoroutine_(IOSTATE, current); } else { //printf("IoCoroutine_rawResume: can't resume coro that hasn't been run - so running it\n"); IoCoroutine_rawRun(self); } return self; }
IoObject *IoCoroutine_run(IoCoroutine *self, IoObject *locals, IoMessage *m) { IoCoroutine_rawRun(self); return IoCoroutine_rawResult(self); }