mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
Issue #17522: Add the PyGILState_Check() API.
This commit is contained in:
parent
d4296fc19c
commit
684cd0e643
4 changed files with 28 additions and 0 deletions
|
@ -697,6 +697,15 @@ PyGILState_GetThisThreadState(void)
|
|||
return (PyThreadState *)PyThread_get_key_value(autoTLSkey);
|
||||
}
|
||||
|
||||
int
|
||||
PyGILState_Check(void)
|
||||
{
|
||||
/* can't use PyThreadState_Get() since it will assert that it has the GIL */
|
||||
PyThreadState *tstate = (PyThreadState*)_Py_atomic_load_relaxed(
|
||||
&_PyThreadState_Current);
|
||||
return tstate && (tstate == PyGILState_GetThisThreadState());
|
||||
}
|
||||
|
||||
PyGILState_STATE
|
||||
PyGILState_Ensure(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue