mirror of
https://github.com/python/cpython.git
synced 2025-10-20 00:13:47 +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
|
@ -130,6 +130,15 @@ PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op)
|
|||
#endif
|
||||
}
|
||||
|
||||
#undef PyCriticalSection_BeginMutex
|
||||
void
|
||||
PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m)
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyCriticalSection_BeginMutex(c, m);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef PyCriticalSection_End
|
||||
void
|
||||
PyCriticalSection_End(PyCriticalSection *c)
|
||||
|
@ -148,6 +157,15 @@ PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b)
|
|||
#endif
|
||||
}
|
||||
|
||||
#undef PyCriticalSection2_BeginMutex
|
||||
void
|
||||
PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2)
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyCriticalSection2_BeginMutex(c, m1, m2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef PyCriticalSection2_End
|
||||
void
|
||||
PyCriticalSection2_End(PyCriticalSection2 *c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue