24 #if defined(WITH_THREAD) && !defined(PYPY_VERSION) 60 tstate = PyGILState_GetThisThreadState();
64 tstate = PyThreadState_New(
internals.istate);
65 # if defined(PYBIND11_DETAILED_ERROR_MESSAGES) 67 pybind11_fail(
"scoped_acquire: could not create thread state!");
70 tstate->gilstate_counter = 0;
77 PyEval_AcquireThread(tstate);
83 void inc_ref() { ++tstate->gilstate_counter; }
86 --tstate->gilstate_counter;
87 # if defined(PYBIND11_DETAILED_ERROR_MESSAGES) 89 pybind11_fail(
"scoped_acquire::dec_ref(): thread state must be current!");
91 if (tstate->gilstate_counter < 0) {
92 pybind11_fail(
"scoped_acquire::dec_ref(): reference count underflow!");
95 if (tstate->gilstate_counter == 0) {
96 # if defined(PYBIND11_DETAILED_ERROR_MESSAGES) 101 PyThreadState_Clear(tstate);
103 PyThreadState_DeleteCurrent();
125 PyThreadState *tstate =
nullptr;
138 tstate = PyEval_SaveThread();
160 PyEval_RestoreThread(tstate);
171 PyThreadState *tstate;
175 #elif defined(PYPY_VERSION) 177 PyGILState_STATE
state;
186 PyThreadState *
state;
const gtsam::Symbol key('X', 0)
PYBIND11_NOINLINE internals & get_internals()
Return a reference to the current internals data.
#define PYBIND11_NAMESPACE
PyExc_RuntimeError [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
#define PYBIND11_TLS_DELETE_VALUE(key)
PyThreadState * get_thread_state_unchecked()
#define PYBIND11_TLS_REPLACE_VALUE(key, value)
#define PYBIND11_TLS_GET_VALUE(key)
#define PYBIND11_NOINLINE
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)