-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed
Labels
topic-free-threadingtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
Description
Throughout the codebase, there are two common patterns for using a mutex only on the free-threaded build:
#ifdef Py_GIL_DISABLED
PyMutex_Lock(/* ... */);
#endif
/* ... */
#ifdef Py_GIL_DISABLED
PyMutex_Unlock(/* ... */);
#endif
#ifdef Py_GIL_DISABLED
#define LOCK() PyMutex_Lock(/* ... */)
#define UNLOCK() PyMutex_Unlock(/* ... */)
#else
#define LOCK()
#define UNLOCK()
#endif
static void
something()
{
LOCK();
/* ... */
UNLOCK();
}
I think we can eliminate some redundancy by adding a common wrapper similar to the latter, but takes a mutex argument rather than being hardcoded into the macro.
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-free-threadingtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)