Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pycore_uniqueid.h58 linesDownload Raw Back to internal
1#ifndef Py_INTERNAL_UNIQUEID_H2#define Py_INTERNAL_UNIQUEID_H3#ifdef __cplusplus4extern "C" {5#endif6 7#ifndef Py_BUILD_CORE8#  error "this header requires Py_BUILD_CORE define"9#endif10 11#ifdef Py_GIL_DISABLED12 13// This contains code for allocating unique ids to objects for per-thread14// reference counting.15//16// Per-thread reference counting is used along with deferred reference17// counting to avoid scaling bottlenecks due to reference count contention.18//19// An id of 0 is used to indicate that an object doesn't use per-thread20// refcounting. This value is used when the object is finalized by the GC21// and during interpreter shutdown to allow the object to be22// deallocated promptly when the object's refcount reaches zero.23//24// Each entry implicitly represents a unique id based on its offset in the25// table. Non-allocated entries form a free-list via the 'next' pointer.26// Allocated entries store the corresponding PyObject.27 28#define _Py_INVALID_UNIQUE_ID 029 30// Assigns the next id from the pool of ids.31extern Py_ssize_t _PyObject_AssignUniqueId(PyObject *obj);32 33// Releases the allocated id back to the pool.34extern void _PyObject_ReleaseUniqueId(Py_ssize_t unique_id);35 36// Releases the allocated id back to the pool.37extern void _PyObject_DisablePerThreadRefcounting(PyObject *obj);38 39// Merges the per-thread reference counts into the corresponding objects.40extern void _PyObject_MergePerThreadRefcounts(_PyThreadStateImpl *tstate);41 42// Like _PyObject_MergePerThreadRefcounts, but also frees the per-thread43// array of refcounts.44extern void _PyObject_FinalizePerThreadRefcounts(_PyThreadStateImpl *tstate);45 46// Frees the interpreter's pool of type ids.47extern void _PyObject_FinalizeUniqueIdPool(PyInterpreterState *interp);48 49// Increfs the object, resizing the thread-local refcount array if necessary.50PyAPI_FUNC(void) _PyObject_ThreadIncrefSlow(PyObject *obj, size_t idx);51 52#endif   /* Py_GIL_DISABLED */53 54#ifdef __cplusplus55}56#endif57#endif   /* !Py_INTERNAL_UNIQUEID_H */58