Skip to content

Commit d3b5547

Browse files
committed
Use a clearer name for field indicating whether or not threads are waiting
1 parent ad5217a commit d3b5547

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Modules/_queuemodule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef struct {
189189
PyObject_HEAD
190190

191191
// Are there threads waiting for items
192-
uint8_t threads_waiting;
192+
bool has_threads_waiting;
193193

194194
// Items in the queue
195195
RingBuf buf;
@@ -276,7 +276,7 @@ maybe_unparked_thread(HandoffData *data, PyObject **item, int has_more_waiters)
276276
*item = data->item;
277277
data->handed_off = 1;
278278
}
279-
data->queue->threads_waiting = has_more_waiters;
279+
data->queue->has_threads_waiting = has_more_waiters;
280280
}
281281

282282
/*[clinic input]
@@ -303,9 +303,9 @@ _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item,
303303
.item = Py_NewRef(item),
304304
.queue = self,
305305
};
306-
if (self->threads_waiting) {
306+
if (self->has_threads_waiting) {
307307
// Try to hand the item off directly if there are threads waiting
308-
_PyParkingLot_Unpark(&self->threads_waiting,
308+
_PyParkingLot_Unpark(&self->has_threads_waiting,
309309
(_Py_unpark_fn_t *)maybe_unparked_thread, &data);
310310
}
311311
if (!data.handed_off) {
@@ -407,11 +407,11 @@ _queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls,
407407
}
408408

409409
uint8_t waiting = 1;
410-
self->threads_waiting = waiting;
410+
self->has_threads_waiting = waiting;
411411

412412
PyObject *item = NULL;
413-
int st = _PyParkingLot_Park(&self->threads_waiting, &waiting,
414-
sizeof(uint8_t), timeout_ns, &item,
413+
int st = _PyParkingLot_Park(&self->has_threads_waiting, &waiting,
414+
sizeof(bool), timeout_ns, &item,
415415
/* detach */ 1);
416416
switch (st) {
417417
case Py_PARK_OK: {

0 commit comments

Comments
 (0)