Commit 2b8eae9b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Implement trashcan behavior

parent 06024f96
......@@ -1154,10 +1154,33 @@ PyObject* _PyTrash_delete_later = NULL;
}
extern "C" void _PyTrash_thread_deposit_object(PyObject* op) noexcept {
Py_FatalError("unimplemented");
PyThreadState* tstate = PyThreadState_GET();
assert(PyObject_IS_GC(op));
assert(_Py_AS_GC(op)->gc.gc_refs == _PyGC_REFS_UNTRACKED);
assert(op->ob_refcnt == 0);
_Py_AS_GC(op)->gc.gc_prev = (PyGC_Head*)tstate->trash_delete_later;
tstate->trash_delete_later = op;
}
extern "C" void _PyTrash_thread_destroy_chain() noexcept {
Py_FatalError("unimplemented");
PyThreadState* tstate = PyThreadState_GET();
while (tstate->trash_delete_later) {
PyObject* op = tstate->trash_delete_later;
destructor dealloc = Py_TYPE(op)->tp_dealloc;
tstate->trash_delete_later = (PyObject*)_Py_AS_GC(op)->gc.gc_prev;
/* Call the deallocator directly. This used to try to
* fool Py_DECREF into calling it indirectly, but
* Py_DECREF was already called on this object, and in
* assorted non-release builds calling Py_DECREF again ends
* up distorting allocation statistics.
*/
assert(op->ob_refcnt == 0);
++tstate->trash_delete_nesting;
(*dealloc)(op);
--tstate->trash_delete_nesting;
}
}
#ifdef Py_TRACE_REFS
......
t = ()
for i in xrange(10000):
t = (t,)
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