Commit d6c8862d authored by Kirill Smelkov's avatar Kirill Smelkov

libgolang: _selcase: Rename .data -> .ptxrx

In the next patches we are going to teach _selcase to support both
external and inplace data. Before that let's do a couple of preparatory
things.

This patch: rename .data -> .ptxrx . The new name is more clear:

- "p" prefix aligns with other libgolang style, e.g. ptx or prx.
- "txrx" suffix says that this is used for both send and recv.

Just plain renaming, nothing else in this patch.
parent e9180de1
...@@ -105,7 +105,7 @@ cdef extern from "golang/libgolang.h" namespace "golang" nogil: ...@@ -105,7 +105,7 @@ cdef extern from "golang/libgolang.h" namespace "golang" nogil:
_DEFAULT _DEFAULT
struct _selcase: struct _selcase:
_chanop op _chanop op
void *data void *ptxrx
cbool *rxok cbool *rxok
const _selcase default "golang::_default" const _selcase default "golang::_default"
......
...@@ -331,7 +331,7 @@ def pyselect(*pycasev): ...@@ -331,7 +331,7 @@ def pyselect(*pycasev):
# decref not sent tx (see ^^^ send prepare) # decref not sent tx (see ^^^ send prepare)
for i in range(n): for i in range(n):
if casev[i].op == _CHANSEND and (i != selected): if casev[i].op == _CHANSEND and (i != selected):
p_tx = <PyObject **>casev[i].data p_tx = <PyObject **>casev[i].ptxrx
_tx = p_tx[0] _tx = p_tx[0]
tx = <object>_tx tx = <object>_tx
Py_DECREF(tx) Py_DECREF(tx)
......
...@@ -154,7 +154,7 @@ enum _chanop { ...@@ -154,7 +154,7 @@ enum _chanop {
typedef struct _selcase { typedef struct _selcase {
_chan *ch; // channel _chan *ch; // channel
enum _chanop op; // chansend/chanrecv/default enum _chanop op; // chansend/chanrecv/default
void *data; // chansend: ptx; chanrecv: prx void *ptxrx; // chansend: ptx; chanrecv: prx
bool *rxok; // chanrecv: where to save ok if !NULL; otherwise not used bool *rxok; // chanrecv: where to save ok if !NULL; otherwise not used
} _selcase; } _selcase;
...@@ -166,7 +166,7 @@ _selcase _selsend(_chan *ch, const void *ptx) { ...@@ -166,7 +166,7 @@ _selcase _selsend(_chan *ch, const void *ptx) {
_selcase _ = { _selcase _ = {
.ch = ch, .ch = ch,
.op = _CHANSEND, .op = _CHANSEND,
.data = (void *)ptx, .ptxrx = (void *)ptx,
.rxok = NULL, .rxok = NULL,
}; };
return _; return _;
...@@ -178,7 +178,7 @@ _selcase _selrecv(_chan *ch, void *prx) { ...@@ -178,7 +178,7 @@ _selcase _selrecv(_chan *ch, void *prx) {
_selcase _ = { _selcase _ = {
.ch = ch, .ch = ch,
.op = _CHANRECV, .op = _CHANRECV,
.data = prx, .ptxrx = prx,
.rxok = NULL, .rxok = NULL,
}; };
return _; return _;
...@@ -190,7 +190,7 @@ _selcase _selrecv_(_chan *ch, void *prx, bool *pok) { ...@@ -190,7 +190,7 @@ _selcase _selrecv_(_chan *ch, void *prx, bool *pok) {
_selcase _ = { _selcase _ = {
.ch = ch, .ch = ch,
.op = _CHANRECV, .op = _CHANRECV,
.data = prx, .ptxrx = prx,
.rxok = pok, .rxok = pok,
}; };
return _; return _;
......
...@@ -859,7 +859,7 @@ void _chan::_dataq_popleft(void *prx) { ...@@ -859,7 +859,7 @@ void _chan::_dataq_popleft(void *prx) {
const _selcase _default = { const _selcase _default = {
.ch = NULL, .ch = NULL,
.op = _DEFAULT, .op = _DEFAULT,
.data = NULL, .ptxrx = NULL,
.rxok = NULL, .rxok = NULL,
}; };
...@@ -916,7 +916,7 @@ int _chanselect(const _selcase *casev, int casec) { ...@@ -916,7 +916,7 @@ int _chanselect(const _selcase *casev, int casec) {
if (ch != NULL) { // nil chan is never ready if (ch != NULL) { // nil chan is never ready
ch->_mu.lock(); ch->_mu.lock();
if (1) { if (1) {
bool done = ch->_trysend(cas->data); bool done = ch->_trysend(cas->ptxrx);
if (done) if (done)
return n; return n;
} }
...@@ -930,7 +930,7 @@ int _chanselect(const _selcase *casev, int casec) { ...@@ -930,7 +930,7 @@ int _chanselect(const _selcase *casev, int casec) {
if (ch != NULL) { // nil chan is never ready if (ch != NULL) { // nil chan is never ready
ch->_mu.lock(); ch->_mu.lock();
if (1) { if (1) {
bool ok, done = ch->_tryrecv(cas->data, &ok); bool ok, done = ch->_tryrecv(cas->ptxrx, &ok);
if (done) { if (done) {
if (cas->rxok != NULL) if (cas->rxok != NULL)
*cas->rxok = ok; *cas->rxok = ok;
...@@ -1017,12 +1017,12 @@ template<> int _chanselect2</*onstack=*/false>(const _selcase *casev, int casec, ...@@ -1017,12 +1017,12 @@ template<> int _chanselect2</*onstack=*/false>(const _selcase *casev, int casec,
if (cas->ch == NULL) // nil chan if (cas->ch == NULL) // nil chan
continue; continue;
if (cas->op == _CHANSEND) { if (cas->op == _CHANSEND) {
memcpy(ptx, cas->data, cas->ch->_elemsize); memcpy(ptx, cas->ptxrx, cas->ch->_elemsize);
cas->data = ptx; cas->ptxrx = ptx;
ptx += cas->ch->_elemsize; ptx += cas->ch->_elemsize;
} }
else if (cas->op == _CHANRECV) { else if (cas->op == _CHANRECV) {
cas->data = rxtxdata; cas->ptxrx = rxtxdata;
} else { } else {
bug("select: invalid op ; _chanselect2: !onstack: B"); bug("select: invalid op ; _chanselect2: !onstack: B");
} }
...@@ -1037,8 +1037,8 @@ template<> int _chanselect2</*onstack=*/false>(const _selcase *casev, int casec, ...@@ -1037,8 +1037,8 @@ template<> int _chanselect2</*onstack=*/false>(const _selcase *casev, int casec,
_selcase *cas = &casev_onheap[selected]; _selcase *cas = &casev_onheap[selected];
if (cas->op == _CHANRECV) { if (cas->op == _CHANRECV) {
const _selcase *cas0 = &casev[selected]; const _selcase *cas0 = &casev[selected];
if (cas0->data != NULL) if (cas0->ptxrx != NULL)
memcpy(cas0->data, cas->data, cas->ch->_elemsize); memcpy(cas0->ptxrx, cas->ptxrx, cas->ch->_elemsize);
} }
return selected; return selected;
...@@ -1084,7 +1084,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv ...@@ -1084,7 +1084,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv
// send // send
if (cas->op == _CHANSEND) { if (cas->op == _CHANSEND) {
bool done = ch->_trysend(cas->data); bool done = ch->_trysend(cas->ptxrx);
if (done) { if (done) {
g->which = &_sel_txrx_prepoll_won; // !NULL not to let already queued cases win g->which = &_sel_txrx_prepoll_won; // !NULL not to let already queued cases win
return n; return n;
...@@ -1095,7 +1095,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv ...@@ -1095,7 +1095,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv
_RecvSendWaiting *w = &waitv[waitc++]; _RecvSendWaiting *w = &waitv[waitc++];
w->init(g, ch); w->init(g, ch);
w->pdata = cas->data; w->pdata = cas->ptxrx;
w->ok = false; w->ok = false;
w->sel_n = n; w->sel_n = n;
...@@ -1104,7 +1104,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv ...@@ -1104,7 +1104,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv
// recv // recv
else if (cas->op == _CHANRECV) { else if (cas->op == _CHANRECV) {
bool ok, done = ch->_tryrecv(cas->data, &ok); bool ok, done = ch->_tryrecv(cas->ptxrx, &ok);
if (done) { if (done) {
g->which = &_sel_txrx_prepoll_won; // !NULL not to let already queued cases win g->which = &_sel_txrx_prepoll_won; // !NULL not to let already queued cases win
if (cas->rxok != NULL) if (cas->rxok != NULL)
...@@ -1117,7 +1117,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv ...@@ -1117,7 +1117,7 @@ static int __chanselect2(const _selcase *casev, int casec, const vector<int>& nv
_RecvSendWaiting *w = &waitv[waitc++]; _RecvSendWaiting *w = &waitv[waitc++];
w->init(g, ch); w->init(g, ch);
w->pdata = cas->data; w->pdata = cas->ptxrx;
w->ok = false; w->ok = false;
w->sel_n = n; w->sel_n = n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment