Skip to content

Commit 414cfef

Browse files
committed
Add threads.mutex member to PyInterpreState
1 parent 782217f commit 414cfef

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Include/internal/pycore_interp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ struct _is {
139139
or the size specified by the THREAD_STACK_SIZE macro. */
140140
/* Used in Python/thread.c. */
141141
size_t stacksize;
142+
/* The mutex lock of the current executing thread. */
143+
PyMutex mutex;
142144
} threads;
143145

144146
/* Reference to the _PyRuntime global variable. This field exists

Include/internal/pycore_pystate.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ extern int _PyOS_InterruptOccurred(PyThreadState *tstate);
263263
#define HEAD_UNLOCK(runtime) \
264264
PyMutex_Unlock(&(runtime)->interpreters.mutex)
265265

266+
#define INTERP_THREAD_LOCK(interpstate) \
267+
PyMutex_LockFlags(&(interpstate)->threads.mutex, _Py_LOCK_DONT_DETACH)
268+
#define INTERP_THREAD_UNLOCK(interpstate) \
269+
PyMutex_Unlock(&(interpstate)->threads.mutex)
270+
266271
// Get the configuration of the current interpreter.
267272
// The caller must hold the GIL.
268273
// Export for test_peg_generator.

0 commit comments

Comments
 (0)