summaryrefslogtreecommitdiffstats
path: root/Python/critical_section.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-140795: fetch thread state once on fast path for critical sections (#141406)Kumar Aditya2025-11-211-10/+8
|
* gh-114203: skip locking if object is already locked by two-mutex critical ↵Kumar Aditya2025-11-141-5/+18
| | | | section (#141476)
* gh-133296: Publicly expose critical section API that accepts PyMutex (gh-135899)Nathan Goldbaum2025-07-211-0/+18
| | | | | | | | | | | | | | | 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`).
* gh-114203: Optimise simple recursive critical sections (#128126)T. Wouters2024-12-231-7/+17
| | | | | | | Add a fast path to (single-mutex) critical section locking _iff_ the mutex is already held by the currently active, top-most critical section of this thread. This can matter a lot for indirectly recursive critical sections without intervening critical sections.
* gh-119344: Make critical section API public (#119353)Sam Gross2024-06-211-29/+77
| | | | | | | | | | This makes the following macros public as part of the non-limited C-API for locking a single object or two objects at once. * `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()` * `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()` The supporting functions and structs used by the macros are also exposed for cases where C macros are not available.
* gh-117511: Make PyMutex public in the non-limited API (#117731)Sam Gross2024-06-201-1/+1
|
* gh-111569: Implement Python critical section API (gh-111571)Sam Gross2023-11-081-0/+100
Critical sections are helpers to replace the global interpreter lock with finer grained locking. They provide similar guarantees to the GIL and avoid the deadlock risk that plain locking involves. Critical sections are implicitly ended whenever the GIL would be released. They are resumed when the GIL would be acquired. Nested critical sections behave as if the sections were interleaved.