Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
29310c47
Commit
29310c47
authored
Nov 08, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28003: Make WrappedVal, ASend and AThrow GC types
parent
49ffdf6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
14 deletions
+48
-14
Objects/genobject.c
Objects/genobject.c
+48
-14
No files found.
Objects/genobject.c
View file @
29310c47
...
...
@@ -1503,14 +1503,14 @@ PyAsyncGen_ClearFreeLists(void)
_PyAsyncGenWrappedValue
*
o
;
o
=
ag_value_freelist
[
--
ag_value_freelist_free
];
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
PyObject_Del
(
o
);
PyObject_
GC_
Del
(
o
);
}
while
(
ag_asend_freelist_free
)
{
PyAsyncGenASend
*
o
;
o
=
ag_asend_freelist
[
--
ag_asend_freelist_free
];
assert
(
Py_TYPE
(
o
)
==
&
_PyAsyncGenASend_Type
);
PyObject_Del
(
o
);
PyObject_
GC_
Del
(
o
);
}
return
ret
;
...
...
@@ -1557,16 +1557,25 @@ async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result)
static
void
async_gen_asend_dealloc
(
PyAsyncGenASend
*
o
)
{
_PyObject_GC_UNTRACK
((
PyObject
*
)
o
);
Py_CLEAR
(
o
->
ags_gen
);
Py_CLEAR
(
o
->
ags_sendval
);
if
(
ag_asend_freelist_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
PyAsyncGenASend_CheckExact
(
o
));
ag_asend_freelist
[
ag_asend_freelist_free
++
]
=
o
;
}
else
{
PyObject_Del
(
o
);
PyObject_
GC_
Del
(
o
);
}
}
static
int
async_gen_asend_traverse
(
PyAsyncGenASend
*
o
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
o
->
ags_gen
);
Py_VISIT
(
o
->
ags_sendval
);
return
0
;
}
static
PyObject
*
async_gen_asend_send
(
PyAsyncGenASend
*
o
,
PyObject
*
arg
)
...
...
@@ -1668,9 +1677,9 @@ PyTypeObject _PyAsyncGenASend_Type = {
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
(
traverseproc
)
async_gen_asend_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
...
...
@@ -1699,7 +1708,7 @@ async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
o
=
ag_asend_freelist
[
ag_asend_freelist_free
];
_Py_NewReference
((
PyObject
*
)
o
);
}
else
{
o
=
PyObject_New
(
PyAsyncGenASend
,
&
_PyAsyncGenASend_Type
);
o
=
PyObject_
GC_
New
(
PyAsyncGenASend
,
&
_PyAsyncGenASend_Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
...
...
@@ -1712,6 +1721,8 @@ async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
o
->
ags_sendval
=
sendval
;
o
->
ags_state
=
AWAITABLE_STATE_INIT
;
_PyObject_GC_TRACK
((
PyObject
*
)
o
);
return
(
PyObject
*
)
o
;
}
...
...
@@ -1722,16 +1733,26 @@ async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
static
void
async_gen_wrapped_val_dealloc
(
_PyAsyncGenWrappedValue
*
o
)
{
_PyObject_GC_UNTRACK
((
PyObject
*
)
o
);
Py_CLEAR
(
o
->
agw_val
);
if
(
ag_value_freelist_free
<
_PyAsyncGen_MAXFREELIST
)
{
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
ag_value_freelist
[
ag_value_freelist_free
++
]
=
o
;
}
else
{
PyObject_Del
(
o
);
PyObject_
GC_
Del
(
o
);
}
}
static
int
async_gen_wrapped_val_traverse
(
_PyAsyncGenWrappedValue
*
o
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
o
->
agw_val
);
return
0
;
}
PyTypeObject
_PyAsyncGenWrappedValue_Type
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"async_generator_wrapped_value"
,
/* tp_name */
...
...
@@ -1753,9 +1774,9 @@ PyTypeObject _PyAsyncGenWrappedValue_Type = {
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
(
traverseproc
)
async_gen_wrapped_val_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
...
...
@@ -1787,13 +1808,15 @@ _PyAsyncGenValueWrapperNew(PyObject *val)
assert
(
_PyAsyncGenWrappedValue_CheckExact
(
o
));
_Py_NewReference
((
PyObject
*
)
o
);
}
else
{
o
=
PyObject_New
(
_PyAsyncGenWrappedValue
,
&
_PyAsyncGenWrappedValue_Type
);
o
=
PyObject_GC_New
(
_PyAsyncGenWrappedValue
,
&
_PyAsyncGenWrappedValue_Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
}
o
->
agw_val
=
val
;
Py_INCREF
(
val
);
_PyObject_GC_TRACK
((
PyObject
*
)
o
);
return
(
PyObject
*
)
o
;
}
...
...
@@ -1804,9 +1827,19 @@ _PyAsyncGenValueWrapperNew(PyObject *val)
static
void
async_gen_athrow_dealloc
(
PyAsyncGenAThrow
*
o
)
{
_PyObject_GC_UNTRACK
((
PyObject
*
)
o
);
Py_CLEAR
(
o
->
agt_gen
);
Py_CLEAR
(
o
->
agt_args
);
PyObject_Del
(
o
);
PyObject_GC_Del
(
o
);
}
static
int
async_gen_athrow_traverse
(
PyAsyncGenAThrow
*
o
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
o
->
agt_gen
);
Py_VISIT
(
o
->
agt_args
);
return
0
;
}
...
...
@@ -1990,9 +2023,9 @@ PyTypeObject _PyAsyncGenAThrow_Type = {
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
(
traverseproc
)
async_gen_athrow_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
...
...
@@ -2016,7 +2049,7 @@ static PyObject *
async_gen_athrow_new
(
PyAsyncGenObject
*
gen
,
PyObject
*
args
)
{
PyAsyncGenAThrow
*
o
;
o
=
PyObject_New
(
PyAsyncGenAThrow
,
&
_PyAsyncGenAThrow_Type
);
o
=
PyObject_
GC_
New
(
PyAsyncGenAThrow
,
&
_PyAsyncGenAThrow_Type
);
if
(
o
==
NULL
)
{
return
NULL
;
}
...
...
@@ -2025,5 +2058,6 @@ async_gen_athrow_new(PyAsyncGenObject *gen, PyObject *args)
o
->
agt_state
=
AWAITABLE_STATE_INIT
;
Py_INCREF
(
gen
);
Py_XINCREF
(
args
);
_PyObject_GC_TRACK
((
PyObject
*
)
o
);
return
(
PyObject
*
)
o
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment