PyObject * PyChannel_Receive_nr(PyChannelObject *self) { PyObject *ret; STACKLESS_PROPOSE_ALL(); ret = impl_channel_receive(self); STACKLESS_ASSERT(); return ret; }
static PyObject * run_cframe(PyFrameObject *f, int exc, PyObject *retval) { PyThreadState *ts = PyThreadState_GET(); PyCFrameObject *cf = (PyCFrameObject*) f; PyTaskletObject *task = ts->st.current; int done = cf->i; ts->frame = f; if (retval == NULL || done) goto exit_run_cframe; if (cf->ob2 == NULL) cf->ob2 = PyTuple_New(0); Py_DECREF(retval); STACKLESS_PROPOSE_ALL(); retval = PyObject_Call(cf->ob1, cf->ob2, cf->ob3); STACKLESS_ASSERT(); cf->i = 1; /* mark ourself as done */ if (STACKLESS_UNWINDING(retval)) { /* try to shortcut */ if (ts->st.current == task && ts->frame != NULL && ts->frame->f_back == (PyFrameObject *) cf) { Py_DECREF(ts->frame->f_back); ts->frame->f_back = cf->f_back; Py_DECREF(cf); /* the exec reference */ } return retval; } /* pop frame */ exit_run_cframe: ts->frame = cf->f_back; Py_DECREF(cf); return retval; }
PyObject * channel_seq_callback(PyFrameObject *_f, int exc, PyObject *retval) { PyThreadState *ts; PyCFrameObject *f = (PyCFrameObject *) _f; PyChannelObject *ch; PyChannel_HeapType *t; PyObject *item; int stage = f->n; /* prolog to re-enter the loop */ if (stage == 1) { item = retval; goto back_with_data; } if (retval == NULL) goto exit_frame; Py_DECREF(retval); retval = NULL; if (stage == 2) { goto back_from_send; } /* Run iterator to exhaustion. */ for (; ; f->i++) { /* get the data */ STACKLESS_PROPOSE_ALL(); item = PyIter_Next(f->ob1); if (STACKLESS_UNWINDING(item)) { stage = f->n = 1; return item; } back_with_data: if (item == NULL) { if (PyErr_Occurred()) { if (PyErr_ExceptionMatches( PyExc_StopIteration)) PyErr_Clear(); else goto exit_frame; } break; } /* send the data */ ch = (PyChannelObject *) f->ob2; t = (PyChannel_HeapType *) Py_TYPE(ch); STACKLESS_PROPOSE_ALL(); retval = t->send(ch, item); Py_DECREF(item); if (retval == NULL) goto exit_frame; if (STACKLESS_UNWINDING(retval)) { stage = f->n = 2; return retval; } Py_DECREF(retval); back_from_send: ; } retval = PyLong_FromLong(f->i); exit_frame: /* epilog to return from the frame */ ts = PyThreadState_GET(); ts->frame = f->f_back; Py_DECREF(f); return retval; }
PyObject * PyStackless_Schedule_nr(PyObject *retval, int remove) { STACKLESS_PROPOSE_ALL(); return PyStackless_Schedule(retval, remove); }
int PyChannel_Send_nr(PyChannelObject *self, PyObject *arg) { STACKLESS_PROPOSE_ALL(); return slp_return_wrapper(impl_channel_send(self, arg)); }