mirror of
https://github.com/python/cpython.git
synced 2025-09-02 23:18:25 +00:00
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
The _thread.RLock type now fully implement the GC protocol: add a traverse function and the Py_TPFLAGS_HAVE_GC flag.
This commit is contained in:
parent
10a5c806d4
commit
1cd3d859a4
2 changed files with 12 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
The _thread.RLock type now fully implement the GC protocol: add a traverse
|
||||||
|
function and the :const:`Py_TPFLAGS_HAVE_GC` flag. Patch by Victor Stinner.
|
|
@ -327,6 +327,14 @@ typedef struct {
|
||||||
PyObject *in_weakreflist;
|
PyObject *in_weakreflist;
|
||||||
} rlockobject;
|
} rlockobject;
|
||||||
|
|
||||||
|
static int
|
||||||
|
rlock_traverse(rlockobject *self, visitproc visit, void *arg)
|
||||||
|
{
|
||||||
|
Py_VISIT(Py_TYPE(self));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rlock_dealloc(rlockobject *self)
|
rlock_dealloc(rlockobject *self)
|
||||||
{
|
{
|
||||||
|
@ -579,13 +587,14 @@ static PyType_Slot rlock_type_slots[] = {
|
||||||
{Py_tp_alloc, PyType_GenericAlloc},
|
{Py_tp_alloc, PyType_GenericAlloc},
|
||||||
{Py_tp_new, rlock_new},
|
{Py_tp_new, rlock_new},
|
||||||
{Py_tp_members, rlock_type_members},
|
{Py_tp_members, rlock_type_members},
|
||||||
|
{Py_tp_traverse, rlock_traverse},
|
||||||
{0, 0},
|
{0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyType_Spec rlock_type_spec = {
|
static PyType_Spec rlock_type_spec = {
|
||||||
.name = "_thread.RLock",
|
.name = "_thread.RLock",
|
||||||
.basicsize = sizeof(rlockobject),
|
.basicsize = sizeof(rlockobject),
|
||||||
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
|
||||||
.slots = rlock_type_slots,
|
.slots = rlock_type_slots,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue