static PyObject * tasklet_get_channel(PyTaskletObject *task) { PyTaskletObject *prev = task->prev; PyObject *ret = Py_None; if (prev != NULL && task->flags.blocked) { /* search left, optimizing in-oder access */ while (!PyChannel_Check(prev)) prev = prev->prev; ret = (PyObject *) prev; } Py_INCREF(ret); return ret; }
PyTaskletObject * slp_channel_remove_slow(PyTaskletObject *task) { int dir; PyChannelObject *channel; PyTaskletObject *prev = task->prev; assert(task->flags.blocked); while (!PyChannel_Check(prev)) prev = prev->prev; channel = (PyChannelObject *) prev; assert(channel->balance); dir = channel->balance > 0 ? 1 : -1; return slp_channel_remove_specific(channel, dir, task);; }
static CHANNEL_SEND_EXCEPTION_HEAD(impl_channel_send_exception) { STACKLESS_GETARG(); PyThreadState *ts = PyThreadState_GET(); PyObject *bomb, *ret = NULL; assert(PyChannel_Check(self)); if (ts->st.main == NULL) return PyChannel_SendException_M(self, klass, args); bomb = slp_make_bomb(klass, args, "channel.send_exception"); if (bomb != NULL) { ret = generic_channel_action(self, bomb, 1, stackless); Py_DECREF(bomb); } return ret; }
void slp_channel_remove_slow(PyTaskletObject *task, PyChannelObject **u_chan, int *u_dir, PyTaskletObject **u_next) { PyChannelObject *channel; PyTaskletObject *prev = task->prev; assert(task->flags.blocked); while (!PyChannel_Check(prev)) prev = prev->prev; channel = (PyChannelObject *) prev; if (u_chan) *u_chan = channel; slp_channel_remove(channel, task, u_dir, u_next); }
static PyObject * impl_channel_send_throw(PyChannelObject *self, PyObject *exc, PyObject *val, PyObject *tb) { STACKLESS_GETARG(); PyThreadState *ts = PyThreadState_GET(); PyObject *bomb, *ret = NULL; assert(PyChannel_Check(self)); if (ts->st.main == NULL) return PyChannel_SendThrow_M(self, exc, val, tb); bomb = slp_exc_to_bomb(exc, val, tb); if (bomb != NULL) { ret = generic_channel_action(self, bomb, 1, stackless); Py_DECREF(bomb); } return ret; }