mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-133296: Publicly expose critical section API that accepts PyMutex (gh-135899)
This makes the following APIs public: * `Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex),` * `Py_BEGIN_CRITICAL_SECTION2_MUTEX(mutex1, mutex2)` * `void PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *mutex)` * `void PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *mutex1, PyMutex *mutex2)` The macros are identical to the corresponding `Py_BEGIN_CRITICAL_SECTION` and `Py_BEGIN_CRITICAL_SECTION2` macros (e.g., they include braces), but they accept a `PyMutex` instead of an object. The new macros are still paired with the existing END macros (`Py_END_CRITICAL_SECTION`, `Py_END_CRITICAL_SECTION2`).
This commit is contained in:
parent
f183996eb7
commit
89c220b93c
8 changed files with 96 additions and 15 deletions
|
|
@ -73,11 +73,11 @@ class object "PyObject *" "&PyBaseObject_Type"
|
|||
// while the stop-the-world mechanism is active. The slots and flags are read
|
||||
// in many places without holding a lock and without atomics.
|
||||
#define TYPE_LOCK &PyInterpreterState_Get()->types.mutex
|
||||
#define BEGIN_TYPE_LOCK() Py_BEGIN_CRITICAL_SECTION_MUT(TYPE_LOCK)
|
||||
#define BEGIN_TYPE_LOCK() Py_BEGIN_CRITICAL_SECTION_MUTEX(TYPE_LOCK)
|
||||
#define END_TYPE_LOCK() Py_END_CRITICAL_SECTION()
|
||||
|
||||
#define BEGIN_TYPE_DICT_LOCK(d) \
|
||||
Py_BEGIN_CRITICAL_SECTION2_MUT(TYPE_LOCK, &_PyObject_CAST(d)->ob_mutex)
|
||||
Py_BEGIN_CRITICAL_SECTION2_MUTEX(TYPE_LOCK, &_PyObject_CAST(d)->ob_mutex)
|
||||
|
||||
#define END_TYPE_DICT_LOCK() Py_END_CRITICAL_SECTION2()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue