File indexing completed on 2025-11-19 09:50:45
0001 #ifndef Py_INTERNAL_BRC_H
0002 #define Py_INTERNAL_BRC_H
0003
0004 #include <stdint.h>
0005 #include "pycore_llist.h" // struct llist_node
0006 #include "pycore_lock.h" // PyMutex
0007 #include "pycore_object_stack.h" // _PyObjectStack
0008
0009 #ifdef __cplusplus
0010 extern "C" {
0011 #endif
0012
0013 #ifndef Py_BUILD_CORE
0014 # error "this header requires Py_BUILD_CORE define"
0015 #endif
0016
0017 #ifdef Py_GIL_DISABLED
0018
0019
0020 #define _Py_BRC_NUM_BUCKETS 257
0021
0022
0023 struct _brc_bucket {
0024
0025 PyMutex mutex;
0026
0027
0028 struct llist_node root;
0029 };
0030
0031
0032 struct _brc_state {
0033
0034
0035 struct _brc_bucket table[_Py_BRC_NUM_BUCKETS];
0036 };
0037
0038
0039 struct _brc_thread_state {
0040
0041 struct llist_node bucket_node;
0042
0043
0044 uintptr_t tid;
0045
0046
0047 _PyObjectStack objects_to_merge;
0048
0049
0050 _PyObjectStack local_objects_to_merge;
0051 };
0052
0053
0054 void _Py_brc_init_thread(PyThreadState *tstate);
0055 void _Py_brc_remove_thread(PyThreadState *tstate);
0056
0057
0058 void _Py_brc_init_state(PyInterpreterState *interp);
0059
0060 void _Py_brc_after_fork(PyInterpreterState *interp);
0061
0062
0063
0064 void _Py_brc_queue_object(PyObject *ob);
0065
0066
0067 void _Py_brc_merge_refcounts(PyThreadState *tstate);
0068
0069 #endif
0070
0071 #ifdef __cplusplus
0072 }
0073 #endif
0074 #endif