8000 gh-76785: Clean Up the Channels Module by ericsnowcurrently · Pull Request #110568 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-76785: Clean Up the Channels Module #110568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

10000
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drop leading _ from high-level functions.
  • Loading branch information
ericsnowcurrently committed Oct 17, 2023
commit 41a8e829b60158ff22d753fce03cec7b27b9b5ca
52 changes: 26 additions & 26 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ _channelitem_clear(_channelitem *item)
item->next = NULL;

if (item->data != NULL) {
// It was allocated in _channel_send().
// It was allocated in channel_send().
(void)_release_xid_data(item->data, XID_IGNORE_EXC & XID_FREE);
item->data = NULL;
}
Expand Down Expand Up @@ -1785,7 +1785,7 @@ _channel_finish_closing(struct _channel *chan) {
/* "high"-level channel-related functions */

static int64_t
_channel_create(_channels *channels)
channel_create(_channels *channels)
{
PyThread_type_lock mutex = PyThread_allocate_lock();
if (mutex == NULL) {
Expand All @@ -1804,7 +1804,7 @@ _channel_create(_channels *channels)
}

static int
_channel_destroy(_channels *channels, int64_t id)
channel_destroy(_channels *channels, int64_t id)
{
_PyChannelState *chan = NULL;
int err = _channels_remove(channels, id, &chan);
Expand All @@ -1818,8 +1818,8 @@ _channel_destroy(_channels *channels, int64_t id)
}

static int
_channel_send(_channels *channels, int64_t id, PyObject *obj,
_waiting_t *waiting)
channel_send(_channels *channels, int64_t id, PyObject *obj,
_waiting_t *waiting)
{
PyInterpreterState *interp = _get_current_interp();
if (interp == NULL) {
Expand Down Expand Up @@ -1868,7 +1868,7 @@ _channel_send(_channels *channels, int64_t id, PyObject *obj,
}

static void
_channel_clear_sent(_channels *channels, int64_t cid, _waiting_t *waiting)
channel_clear_sent(_channels *channels, int64_t cid, _waiting_t *waiting)
{
// Look up the channel.
PyThread_type_lock mutex = NULL;
Expand All @@ -1889,7 +1889,7 @@ _channel_clear_sent(_channels *channels, int64_t cid, _waiting_t *waiting)
}

static int
_channel_send_wait(_channels *channels, int64_t cid, PyObject *obj,
channel_send_wait(_channels *channels, int64_t cid, PyObject *obj,
PY_TIMEOUT_T timeout)
{
// We use a stack variable here, so we must ensure that &waiting
Expand All @@ -1901,7 +1901,7 @@ _channel_send_wait(_channels *channels, int64_t cid, PyObject *obj,
}

/* Queue up the object. */
int res = _channel_send(channels, cid, obj, &waiting);
int res = channel_send(channels, cid, obj, &waiting);
if (res < 0) {
assert(waiting.status == WAITING_NO_STATUS);
goto finally;
Expand All @@ -1913,7 +1913,7 @@ _channel_send_wait(_channels *channels, int64_t cid, PyObject *obj,
_waiting_finish_releasing(&waiting);
/* The send() call is failing now, so make sure the item
won't be received. */
_channel_clear_sent(channels, cid, &waiting);
channel_clear_sent(channels, cid, &waiting);
assert(waiting.status == WAITING_RELEASED);
if (!waiting.received) {
res = -1;
Expand All @@ -1940,7 +1940,7 @@ _channel_send_wait(_channels *channels, int64_t cid, PyObject *obj,
}

static int
_channel_recv(_channels *channels, int64_t id, PyObject **res)
channel_recv(_channels *channels, int64_t id, PyObject **res)
{
int err;
*res = NULL;
Expand Down Expand Up @@ -1982,14 +1982,14 @@ _channel_recv(_channels *channels, int64_t id, PyObject **res)
PyObject *obj = _PyCrossInterpreterData_NewObject(data);
if (obj == NULL) {
assert(PyErr_Occurred());
// It was allocated in _channel_send(), so we free it.
// It was allocated in channel_send(), so we free it.
(void)_release_xid_data(data, XID_IGNORE_EXC | XID_FREE);
if (waiting != NULL) {
_waiting_release(waiting, 0);
}
return -1;
}
// It was allocated in _channel_send(), so we free it.
// It was allocated in channel_send(), so we free it.
int release_res = _release_xid_data(data, XID_FREE);
if (release_res < 0) {
// The source interpreter has been destroyed already.
Expand All @@ -2011,7 +2011,7 @@ _channel_recv(_channels *channels, int64_t id, PyObject **res)
}

static int
_channel_drop(_channels *channels, int64_t id, int send, int recv)
channel_drop(_channels *channels, int64_t id, int send, int recv)
{
PyInterpreterState *interp = _get_current_interp();
if (interp == NULL) {
Expand All @@ -2034,13 +2034,13 @@ _channel_drop(_channels *channels, int64_t id, int send, int recv)
}

static int
_channel_close(_channels *channels, int64_t id, int end, int force)
channel_close(_channels *channels, int64_t id, int end, int force)
{
return _channels_close(channels, id, NULL, end, force);
}

static int
_channel_is_associated(_channels *channels, int64_t cid, int64_t interp,
channel_is_associated(_channels *channels, int64_t cid, int64_t interp,
int send)
{
_PyChannelState *chan = NULL;
Expand Down Expand Up @@ -2652,7 +2652,7 @@ clear_interpreter(void *data)
static PyObject *
channelsmod_create(PyObject *self, PyObject *Py_UNUSED(ignored))
{
int64_t cid = _channel_create(&_globals.channels);
int64_t cid = channel_create(&_globals.channels);
if (cid < 0) {
(void)handle_channel_error(-1, self, cid);
return NULL;
Expand All @@ -2667,7 +2667,7 @@ channelsmod_create(PyObject *self, PyObject *Py_UNUSED(ignored))
(channelid **)&id);
if (handle_channel_error(err, self, cid)) {
assert(id == NULL);
err = _channel_destroy(&_globals.channels, cid);
err = channel_destroy(&_globals.channels, cid);
if (handle_channel_error(err, self, cid)) {
// XXX issue a warning?
}
Expand Down Expand Up @@ -2697,7 +2697,7 @@ channelsmod_destroy(PyObject *self, PyObject *args, PyObject *kwds)
}
cid = cid_data.cid;

int err = _channel_destroy(&_globals.channels, cid);
int err = channel_destroy(&_globals.channels, cid);
if (handle_channel_error(err, self, cid)) {
return NULL;
}
Expand Down Expand Up @@ -2785,7 +2785,7 @@ channelsmod_list_interpreters(PyObject *self, PyObject *args, PyObject *kwds)
while (interp != NULL) {
id = PyInterpreterState_GetID(interp);
assert(id >= 0);
int res = _channel_is_associated(&_globals.channels, cid, id, send);
int res = channel_is_associated(&_globals.channels, cid, id, send);
if (res < 0) {
(void)handle_channel_error(res, self, cid);
goto except;
Expand Down Expand Up @@ -2847,10 +2847,10 @@ channelsmod_send(PyObject *self, PyObject *args, PyObject *kwds)
/* Queue up the object. */
int err = 0;
if (blocking) {
err = _channel_send_wait(&_globals.channels, cid, obj, timeout);
err = channel_send_wait(&_globals.channels, cid, obj, timeout);
}
else {
err = _channel_send(&_globals.channels, cid, obj, NULL);
err = channel_send(&_globals.channels, cid, obj, NULL);
}
if (handle_channel_error(err, self, cid)) {
return NULL;
Expand Down Expand Up @@ -2896,10 +2896,10 @@ channelsmod_send_buffer(PyObject *self, PyObject *args, PyObject *kwds)
/* Queue up the object. */
int err = 0;
if (blocking) {
err = _channel_send_wait(&_globals.channels, cid, tempobj, timeout);
err = channel_send_wait(&_globals.channels, cid, tempobj, timeout);
}
else {
err = _channel_send(&_globals.channels, cid, tempobj, NULL);
err = channel_send(&_globals.channels, cid, tempobj, NULL);
}
Py_DECREF(tempobj);
if (handle_channel_error(err, self, cid)) {
Expand Down Expand Up @@ -2931,7 +2931,7 @@ channelsmod_recv(PyObject *self, PyObject *args, PyObject *kwds)
cid = cid_data.cid;

PyObject *obj = NULL;
int err = _channel_recv(&_globals.channels, cid, &obj);
int err = channel_recv(&_globals.channels, cid, &obj);
if (handle_channel_error(err, self, cid)) {
return NULL;
}
Expand Down Expand Up @@ -2975,7 +2975,7 @@ channelsmod_close(PyObject *self, PyObject *args, PyObject *kwds)
}
cid = cid_data.cid;

int err = _channel_close(&_globals.channels, cid, send-recv, force);
int err = channel_close(&_globals.channels, cid, send-recv, force);
if (handle_channel_error(err, self, cid)) {
return NULL;
}
Expand Down Expand Up @@ -3036,7 +3036,7 @@ channelsmod_release(PyObject *self, PyObject *args, PyObject *kwds)
// XXX Handle force is True.
// XXX Fix implicit release.

int err = _channel_drop(&_globals.channels, cid, send, recv);
int err = channel_drop(&_globals.channels, cid, send, recv);
if (handle_channel_error(err, self, cid)) {
return NULL;
}
Expand Down
0